Share via


Defining Project Templates

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

A Project template unfolds into one or multiple projects in an existing solution.

If a Guidance Package is enabled, Project templates that are referenced in the Guidance Package can appear in the Add New Project dialog box, if they are located in the Projects templates root folder or one folder below in the Guidance Package solution structure. A Project template never enables its Guidance Package. Therefore, it can be unfolded only if the package has been enabled manually in an existing solution or if the solution was started from a Solution template.

Note

Note: For a Project template to appear in the Add New Project dialog box, there must be a reference associating the template with the solution element that is selected. For more information, see Understanding Visual Studio Templates.

As with a Solution template, a Project template can create bound references and execute recipes. The following XML code example shows a template that creates a sample class library.

<VSTemplate Version="2.0.0" Type="Project" xmlns="https://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>Sample Library Project</Name>
    <Description>Sample class library project </Description>
    <Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4547" />
    <ProjectType>CSharp</ProjectType>
    <SortOrder>20</SortOrder>
    <CreateNewFolder>true</CreateNewFolder>
    <DefaultName>ClassLibrary</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
  </TemplateData>
  <TemplateContent>
    <Project File="SampleLibrary.csproj" ReplaceParameters="true">
      <ProjectItem ReplaceParameters="true">Properties\AssemblyInfo.cs</ProjectItem>
      <ProjectItem ReplaceParameters="true">SampleClass.cs</ProjectItem>
    </Project>
  </TemplateContent>
<WizardExtension>
<Assembly>Microsoft.Practices.RecipeFramework.VisualStudio, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</Assembly>
<FullClassName>Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate</FullClassName>
</WizardExtension>
</VSTemplate>

See also

Developing Visual Studio Templates | Syntax of Visual Studio Templates | Defining Solution Template | Defining Item Template