Visual Studio Template Metadata Files

Each template includes a .vstemplate file with the metadata that provides Visual Studio with the information required to display the template in the New Project and Add New Item dialog boxes and create a project or item from the template.

Structure of a .vstemplate File

The .vstemplate file for project templates consists of three fundamental elements:

  • VSTemplate   Identifies the template as a project or item template and provides the template version number.

  • TemplateData   Categorizes the project template and defines display characteristics for the New Project or Add New Item dialog box.

  • TemplateContent   Specifies the files included in the template.

For example, the following code represents a skeleton .vstemplate file for a project template.

<VSTemplate Type="Project" Version="2.0.0"
    xmlns="https://schemas.microsoft.com/developer/vstemplate/2005">
    <TemplateData>
        ...
    </TemplateData>
    <TemplateContent>
        ...
    </TemplateContent>
</VSTemplate>

Template metadata files are validated by an XML schema that is included with Visual Studio. For more information on the template XML schema, see Visual Studio Template Schema Reference.

Advanced Elements

In addition to the fundamental template XML elements, you can use the WizardExtension and WizardData elements to add custom functionality to the template wizard that creates a new project or item from the template. This custom functionality is achieved by creating an assembly that implements the IWizard interface, and registering that assembly in the .vstemplate file. For more information, see How to: Use Wizards with Project Templates.

Basic Project Template .vstemplate file

The following example shows a custom template for a Visual C# project.

<VSTemplate Type="Project" Version="2.0.0"
    xmlns="https://schemas.microsoft.com/developer/vstemplate/2005">
    <TemplateData>
        <Name>My template</Name>
        <Description>A basic template.</Description>
        <Icon>TemplateIcon.ico</Icon>
        <ProjectType>CSharp</ProjectType>
    </TemplateData>
    <TemplateContent>
        <Project File="MyTemplate.csproj">
            <ProjectItem>Form1.cs<ProjectItem>
            <ProjectItem>Form1.Designer.cs</ProjectItem>
            <ProjectItem>Properties\AssemblyInfo.cs</ProjectItem>
            <ProjectItem>Properties\Resources.resx</ProjectItem>
            <ProjectItem>Properties\Resources.Designer.cs</ProjectItem>
            <ProjectItem>Properties\Settings.settings</ProjectItem>
            <ProjectItem>Properties\Settings.Designer.cs</ProjectItem>
        </Project>
    </TemplateContent>
</VSTemplate>

See Also

Reference

Visual Studio Template Schema Reference

Other Resources

Visual Studio Templates

How to: Select the XML Schema(s) to Use for Validation