Add Foundational Module Template

The guidance package includes two Visual Studio project templates named FoundationalModule.vstemplate (one for C# projects and one for Visual Basic projects). These files can be found under the Templates\Projects\Module.CS and Templates\Projects\Module.VB folders of the WebClientFactoryPackage project. After you register (or install) the guidance package, these templates are available under the Web Client Development October 2007 node in the Add New Project dialog box of Visual Studio. The templates are named Add Foundational Module(C#) and Add Foundational Module (Visual Basic), as shown in Figure 1.
AddFoundationalModuleTemplates.png
Figure 1
Add Foundational Module templates in Visual Studio.

When you use one of these templates to create a new module, the recipe framework displays a wizard that you can use to customize the generated code. Figure 2 illustrates the wizard.
AddFoundationalModuleRecipe.png
Figure 2
Add Foundational Module recipe wizard.

Implementation Details

Both Visual Studio template files contain similar XML that provides the connection between the project templates and the recipe framework. In the case of the C# template file, the WizardData element specifies the CreateFoundationalModuleCS recipe as the recipe that the framework executes when it unfolds the project template.

<WizardData>
  <Template xmlns="http://schemas.microsoft.com/pag/gax-template"
              SchemaVersion="1.0"
              Recipe="CreateFoundationalModuleCS">
  </Template>
</WizardData>

You can find the CreateFoundationalModuleCS definition in the CreateWebClientFactoryFoundationalModule.xml file (this file is located in the Recipes\CS folder of the WebClientFactoryPackage project).
If you select the Create project for unit tests check box, the recipe will generate a test project. To do this, the FoundationalModule.Tests.vstemplate project template is unfolded by the following action.

<!-- Unfold the test project template if needed -->
<Action Condition="$(CreateTestProject)" Name="UnfoldModuleTestProjectTemplate" 
      Type="UnfoldTemplateAction"
      Template="Projects\Module.Tests.CS\FoundationalModule.Tests.vstemplate">
  <Input Name="Root" RecipeArgument="TestProjectContainerSolutionFolder" />
  <Input Name="ItemName" RecipeArgument="ModuleTestProjectName" />
  <Input Name="DestinationFolder" RecipeArgument="ModuleTestProjectPath" />
  <Output Name="NewItem" />
</Action>

Note:
When you add a foundational module to a folder in Visual Studio, the project appears in that folder in Solution Explorer. By default, the Location text box in the Add New Project dialog box does not contain the folder in the path. To create the project in that folder on the hard disk, you must update the Location text box to include the folder in the path.

Add Foundational Module Next Steps

AddFoundationalModuleNextSteps.png

Last edited Nov 12, 2007 at 4:30 PM by siacomuzzi, version 2

Comments

No comments yet.