次の方法で共有


Templates for Creating Templates

The Visual Studio SDK includes a Project Template template and an Item Template template that you can use for template development. These templates include some common parameter substitutions, and build as compressed files instead of as Dynamic Link Libraries (DLLs) or executables.

The template-creation templates let you include template projects in larger extensions without building the individual templates. This lets you implement version control on the source files and build a group of template projects into one VSIX package.

We recommend that you use the Project Template and Item Template templates for the following scenarios:

  • Creating extensions that have multiple templates.

  • Creating extensions that include templates and other components.

  • Any template creation scenarios in which content-level version control is desirable.

  • Any scenarios that are not supported by the Export Template wizards.

For basic template creation scenarios, we recommend that you use the Export Template Wizard (which outputs to a compressed file) or the Export Template Wizard extension (which outputs to a .vsix file.) For scenarios that are not supported by the templates or by the wizards, you can create templates manually. For a comparison of the different template-creation strategies, see Creating Project and Item Templates.

Locations for the Project Template and Item Template Templates

The Project Template and Item Template templates are available in two locations in the New Project dialog box:

  • Under Visual Basic Extensibility. The default language of the project is Visual Basic.

  • Under C# Extensibility. The default language of the project is C#.

Creating a Project Template

To create a project template

  1. Create a Project Template project.

    The template generates an empty class, an icon, a .vstemplate file, an editable project file named ProjectTemplate.vbproj or ProjectTemplate.csproj, and some files that are typically generated by other project types, such a resources.resx file, an AssemblyInfo file, and a .settings file. Each code file contains common parameter substitutions where appropriate.

  2. Add and remove items from the project as required for your project. Do not remove the editable project file, the AssemblyInfo file, or the .vstemplate file.

  3. Update the .vstemplate file to reflect any additions and deletions. The Project element must contain a ProjectItem element for each file to be included in the template.

  4. Modify your code files and other user-facing content, and add appropriate parameter substitutions.

  5. Modify generated content as required.

  6. Build the project.

    Visual Studio creates a compressed file that contains your template.

Creating an Item Template

To create an item template

  1. Create an Item Template project.

    The template generates an empty class, an icon, a .vstemplate file, and an AssemblyInfo file. The class file contains some common parameter substitutions.

  2. Add and remove items from the project as required for your project.

  3. Update the .vstemplate file to reflect any additions and deletions. The Project element must contain a ProjectItem element for each file to be included in the template.

  4. Modify your code files and other user-facing content, and add appropriate parameter substitutions.

  5. Modify generated content as required.

  6. Build the project.

    Visual Studio creates a compressed file that contains your template.

Deployment

To deploy the templates

  1. Create a VSIX project. For more information, see VSIX Project Template.

  2. Open the .vsixmanifest file.

  3. Click Add Content.

    1. For content type, select Project Template or Item Template.

    2. For source, select the Project option, and then select the project that contains your template.

    Repeat this step for each template to be added to your deployment package.

  4. Build the VSIX project.

    Visual Studio creates a deployable .vsix file in the \bin\debug\ folder of your project. For more information about VSIX deployment, see VSIX Deployment.

See Also

Tasks

How to: Use the Template Wizard Extension

Other Resources

Projects and Solutions

Visual Studio Templates

Visual Studio Template Reference