Task 2: Performing an Initial Build of the Application
In this task you will accomplish the following:
- Review the initial configuration file.
- Review the initial application definition file (ADF).
- Review the Notification Services Rebuild command.
- Build your application for the first time using Microsoft Visual Studio® .NET.
Review the Configuration File
Follow these steps to become familiar with the initial configuration file for the walkthrough.
- In the Solution Explorer pane of Visual Studio .NET, expand the AppDefinition project, and then double-click the appConfig.task2.xml file.
At this point you notice that the configuration file contains just a few elements:
- An <InstanceName> element that specifies the Notification Services instance name.
- A <SqlServerSystem> element that specifies the SQL Server instance that will host the Notification Services databases.
- An <Applications> node that contains the basic application information for the Stock sample.
- A <DeliveryChannels> node that defines a delivery channel that uses the standard File delivery protocol provided by Notification Services.
- When you have finished reviewing the configuration file, close the file.
Review the ADF
Follow these steps to read through the initial application definition file for the walkthrough.
- In the Solution Explorer pane, double-click the appADF.task2.xml file to view the ADF.
At this point you notice that the ADF contains these elements:
- A <Version> node that you can use to label the ADF with version information. In this node, the <Build> element contains the portion of the version number that indicates the build of the application. The value of the <Build> element should be updated each time you update the ADF.
- A <History> node that you can use to track when your ADF was originally created and when it was last changed.
- Empty <SubscriptionClasses> and <NotificationClasses> nodes. You will be filling in these nodes during the walkthrough.
- <Generator> and <Distributor> nodes, which contain the name of the system where the generator and distributor run. The system name is passed in as a parameter, specified as %ParameterName%.
- Several basic application execution settings.
- When you have finished reviewing the ADF, close the file.
Review the Notification Services Rebuild Command
In an upcoming walkthrough task, you will invoke the Rebuild command to build your Notification Services application in Visual Studio .NET. The Rebuild command deletes the existing instance and application for this programming sample (if they exist), and then creates a new instance and application for the sample.
The Rebuild command is customized, and works by invoking the RunRebuild.cmd script. Follow these steps to review what the RunRebuild.cmd script does and how it works.
- In the Solution Explorer pane, expand the BuildScripts directory in the AppDefinition project, and then double-click the RunRebuild.cmd script to open it.
Reading through the RunRebuild.cmd script, you notice that it does two things:
- Invokes the NSControl Delete command. In this walkthrough, the command deletes the StockInstanceNSMain and StockInstanceStock databases.
- Invokes the RunCreate.cmd script to re-create the Stock databases.
- When you have finished reviewing the RunRebuild.cmd script, close the file.
- In the BuildScripts directory, double-click the RunCreate.cmd script to open it.
The RunCreate.cmd script does four things:
- Ensures that the Events and Notification subdirectories of the sample directory exist and are empty.
- Invokes the NSControl Create command, passing in the name of your configuration file as an argument. The configuration file contains a reference to the ADF. NSControl Create validates the ADF and the configuration file, and creates the StockInstanceNSMain and StockInstanceStock SQL Server databases.
- Invokes the NSControl Enable command to enable the new instance for the sample.
- Calls the GrantPermissions.cmd script to grant permissions on the instance and application databases to the Web and service accounts.
- When you have finished reviewing the RunCreate.cmd script, close the file.
The output from the Rebuild command is always displayed in the Output pane of Visual Studio .NET. Whenever you invoke the command, always look through the output carefully to verify that the command completed successfully.
Note For more information about the Notification Services commands used in the Visual Studio .NET solutions for the samples, see Programming Sample Structure.
Build the Application
- In the Solution Explorer pane, right-click the AppDefinition project, and then click Rebuild.
A new Stock instance and application are created, overwriting the existing instance and application (if they exist).
- In the Output pane, scroll through the results of the Rebuild command to verify that the command succeeded.
- In the Server Explorer pane, navigate to the StockInstanceNSMain and StockInstanceStock databases.
These are the databases generated by NSControl Create.
- In the Server Explorer pane, click the Services node, and then locate NS$StockInstance.
NS$StockInstance is the name of the Notification Services service that was created by the NSControl Register command when you ran the SetupSamples.cmd script.
Task 2 Summary
After completing all the steps in this task, you should now have a basic understanding of the ADF and configuration file structures, as well as an idea of how the Rebuild command works. You should also have your first build of the application.