Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: Manually Create Web Templates

Creating a Web template is slightly different than creating other types of templates. Because Web project templates appear in the Add New Website 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.

NoteNote:

Web templates must contain a empty .webproj file that is specified with the File attribute of the Project element. Although Web projects do not require project files, this file is required for proper functionality of Web templates.

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 with a .vstemplate extension in the same directory as your project, but 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

    • JSharp

    For example:

    <TemplateData>
        ...
        <ProjectType>Web</ProjectType>
        <ProjectSubType>CSharp</ProjectSubType>
        ...
    </TemplateData>
    
  7. 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.

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

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

<VSTemplate Version="2.0.0" Type="Project"
    xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">>
    <TemplateData>
        <Name>MyWebProjecStarterKit</Name>
        <Description>A simple Web template</Description>
        <Icon>icon.ico</Icon>
        <ProjectType>Web</ProjectType>
        <ProjectSubType>CSharp</ProjectSubType>
        <DefaultName>WebSite</DefaultName>
    </TemplateData>
    <TemplateContent>
        <Project File="WebApplication.webproj">
            <ProjectItem>icon.ico</ProjectItem>
            <ProjectItem OpenInEditor="true">Default.aspx</ProjectItem>
            <ProjectItem>Default.aspx.cs</ProjectItem>
        </Project>
    </TemplateContent>
</VSTemplate>
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.