This documentation is archived and is not being maintained.

How to: Manually Create Project Templates 

Visual Studio provides wizards to help you generate templates from projects that are open in the development environment. However, if you want to create a template outside of the development environment, you can use this procedure to manually assemble the source files of your application into a Visual Studio project template.

The process of creating a custom project template involves designing and developing the project as well as providing metadata about the project template.

Custom project templates require the following items:

  • The metadata file (*.vstemplate) that Visual Studio uses to define how to display the project in the development environment and, if you have specified the appropriate properties, to customize how the project is created in the development environment.

  • The project file.

  • The code files, such as Windows forms, Web forms, class files, and resource files.

All the items are compressed into a single .zip file. The .zip file must be placed in the location recognized by Visual Studio for custom project templates. Custom project templates are listed within each programming language folder in the My Templates section of the New Project dialog box. For more information, see How to: Locate and Organize Project and Item Templates.

To create a template manually

  1. Create a project.

  2. Modify or delete the files in the project, or add new files to the project.

  3. Edit the code files to indicate where parameter replacement should take place. For more information on parameter replacement, see How to: Substitute Parameters in a Template.

  4. Create an XML file and save it with a .vstemplate extension in the same directory as your project, but do not add it to the project in Visual Studio.

  5. Author the .vstemplate XML file to provide project template metadata. For more information, see the example in the following section.

  6. Select the files included in your template (including the .vstemplate file), right-click, select Send To, and click Compressed (zipped) Folder. The files that you previously extracted are compressed into a .zip file.

  7. Place the .zip template file in the Visual Studio project template directory. By default, this directory is My Documents\Visual Studio 2005\Templates\ProjectTemplates.


This example shows a simple .vstemplate metadata file. The TemplateData element specifies the project type, name, description, and icon that are displayed in the New Project dialog box. The TemplateContent element specifies the name of the project file and the files that are in the project. In this example, the project file is named MyStarterKit.csproj, and includes the files that comprise a Visual C++ project.

<VSTemplate Type="Project" Version="2.0.0"
        <Name>My template</Name>
        <Description>A basic template</Description>
        <Project File="MyTemplate.csproj">

See Also