Before learning how to extend the development environment, it's important that you understand how it works. This section explains the directory layout and some of the files involved. The environment you create for your own applications will have the same structure. The Development Environment Directory LayoutWe refer to the directory into which you copied the source files from this book's CD-ROM as the source code base directory. Throughout this book, the name of this directory is assumed to be C:\SQL-NS, although you can give it any name you choose. The following directories exist under the source code base directory:
The Samples directory has a subdirectory called Minimal, which contains the source files for a minimal SQL-NS instance with one application. When you create a new SQL-NS instance, you begin by copying source code for this minimal instance. This gives you a working skeleton of a SQL-NS instance and application to which you can add your own code. The section "Extending the Development Environment" (p. 651) describes the exact steps in this process. Each of the sample subdirectories within the Samples directory contains the code for a complete SQL-NS instance. Throughout the remainder of this appendix, I refer to these directories as instance directories because each one encapsulates the source code for an instance. The directories you create for new SQL-NS instances of your own will have a structure similar to these sample instance directories, so it's important to understand their subdirectory layout. The following subdirectories exist beneath all sample instance directories:
The directories you create for your instances will also have a Scripts subdirectory containing the build scripts and an application directory for each application. Important Files in the Development EnvironmentIn the Common directory under the source code base directory, the setenv.cmd file sets up the environment variables used by the build scripts in all the instance directories. These environment variables provide the location of the source code base directory, the name of the SQL Server, the name of the service user, the SQL authentication mode, and other required information. When you completed the instructions given in the "Environment Variables" section (p. 36) in Chapter 2, you edited setenv.cmd to customize the environment variables for your system. Each instance directory also contains a file called setenv.cmd in its Scripts subdirectory. All the build scripts (batch files that invoke nscontrol create, nscontrol update, and so on) in the Scripts subdirectory call this local setenv.cmd file before invoking any operations. The local setenv.cmd file in the Scripts subdirectory first calls the common setenv.cmd file (in the Common directory, one level up) and then sets up additional environment variables specific to the instance. This establishes the complete environment, including common and instance-specific parts, required by the commands in the build scripts. Note Most of the build scripts in the Scripts directory are explained in detail in Chapter 4, "Working with SQL-NS Instances." As long as the environment variables in the local and common setenv.cmd files are set correctly, the build scripts will work for any instance. When you create a new instance, you usually don't have to change the common setenv.cmd file. However, you will have to create an instance-specific setenv.cmd file in the Scripts subdirectory of the instance directory to establish the instance-specific part of the environment for building the new instance. The "Creating the Directories and Files for a New Instance" section (p. 652) later in this appendix provides instructions for doing this. |