We recommend using Visual Studio 2017

How to: Manually Create Web Templates


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at How to: Manually Create Web Templates.

Creating a Web template is different than creating other kinds of templates. Because Web project templates appear in the Add New Web Site dialog box, and Web project items are categorized by programming language, the .vstemplate file must specify the template as a Web template and identify the programming language.

System_CAPS_ICON_note.jpg Note

Web templates must contain a empty .webproj file that is specified by using the File attribute of the Project element. Although Web projects do not require project files, this file is required so that a Web template functions correctly.

To manually create a Web template

  1. Create a Web project.

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

  3. Create an XML file and save it by using a .vstemplate file name extension, in the same directory as your project. Do not add it to the project in Visual Studio.

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

  5. Locate the ProjectType element in the .vstemplate file, and set the text value to Web.

  6. Following the ProjectType element, add a ProjectSubType element and set the text value to the programming language of the template. The programming language can be one of the following values:

    • CSharp

    • VisualBasic

    For example:

  7. Select the files in your template (this includes the .vstemplate file), right-click the selection, click Send To, and then click Compressed (zipped) Folder. The files are compressed into a .zip file.

  8. Put the .zip template file in the Visual Studio project template directory. By default, this directory is \My Documents\Visual Studio Version\My Exported Templates\.

The following example shows a basic .vstemplate file for a Web project template.

<VSTemplate Version="2.0.0" Type="Project"  
        <Description>A simple Web template</Description>  
        <Project File="WebApplication.webproj">  
            <ProjectItem OpenInEditor="true">Default.aspx</ProjectItem>  

Creating Project and Item Templates
Visual Studio Template Schema Reference