A bare bones .vstemplate file has this format
<VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
<TemplateData>
</TemplateData>
<TemplateContent>
</TemplateContent>
</VSTemplate>
We looked at the <TemplateData> section in the New Project Generation: Under the Hood, Part One. The tags in this section are used to control the appearance of the New Project dialog box.
The tags in the <TemplateContent> section control the generation of new projects and project items. Here's the <TemplateContent> section from the cswindowsapplication.vstemplate file in the \Program Files\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplates\CSharp\Windows\1033\WindowsApplication.zip folder.
<TemplateContent>
<Project File="WindowsApplication.csproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="true"
TargetFileName="Properties\AssemblyInfo.cs">
AssemblyInfo.cs
</ProjectItem>
<ProjectItem TargetFileName="Properties\Resources.resx">
Resources.resx
</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Properties\Resources.Designer.cs">
Resources.Designer.cs
</ProjectItem>
<ProjectItem TargetFileName="Properties\Settings.settings">
Settings.settings
</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Properties\Settings.Designer.cs">
Settings.Designer.cs
</ProjectItem>
<ProjectItem ReplaceParameters="true" OpenInEditor="true">
Form1.cs
</ProjectItem>
<ProjectItem ReplaceParameters="true">
Form1.Designer.cs
</ProjectItem>
<ProjectItem ReplaceParameters="true">
Program.cs
</ProjectItem>
</Project>
</TemplateContent>
The <Project> tag controls the generation of a project, and the <ProjectItem> tag controls the generation of a project item. If the parameter ReplaceParameters is true, the template wizard will customize all template parameters in the project file or item. In this case, all project items are customized, except for Settings.settings.
The TargetFileName parameter specifies the name and relative path of the resulting project file or item. This lets you create a folder structure for your project. If you don't specify this argument, the project item will have the same name as the project item template.
The resulting Windows application folder structure looks like this:
.png)
The first and only <Project> tag in the template reads:
<Project File="WindowsApplication.csproj" ReplaceParameters="true">
This instructs the New Project wizard to create the Simple.csproj project file by copying and customizing the template item windowsapplication.csproj.
Designers and References
You can see in the Solution Explorer that the Properties folder is present and contains the expected files. But what about project references and designer file dependencies, such as Resources.Designer.cs to Resources.resx, and Form1.Designer.cs to Form1.cs? These are set up in the Simple.csproj file when it is generated.
Here's the <ItemGroup> from Simple.csproj that creates the project references:
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
You can see that these are the six project references that appear in the Solution Explorer. Here's a section from another <ItemGroup>. Many lines of code have been deleted for clarity. This section makes Settings.Designer.cs dependent on Settings.settings:
<ItemGroup>
<Compile Include="Properties\Settings.Designer.cs">
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
The managed class ProjectFileConstants exposes <Reference> <DependentUpon> and many other project file tags.