Differences Between Project and Item Templates

Visual Studio templates are divided into two major categories: project templates and item templates. This topic explains some of the differences between project and item templates.

Item Templates

Item templates are individual items that a user can add to a project by using the Add New Item dialog box. Examples of item templates included with Visual Studio are:

  • Windows Form

  • Code File

  • XML Schema

Project Templates

Project templates are entire projects from which a user can create a new project by using the New Project dialog box. A project template includes all the files necessary to begin a specific type of project. Examples of project templates included with Visual Studio are:

  • Windows Application

  • Class Library

  • Empty Project

You can use the wizard that creates projects from templates to perform custom actions. For more information, see How to: Use Wizards with Project Templates.

Contents of Templates

Both item and project templates are stored as .zip files. The contents of the .zip files differ between the different types of templates.

Item template .zip files contain:

  • The .vstemplate file that contains the metadata for the template.

  • One or more files to add to a project when an item is instantiated from the template.

    Note

    Although item templates might only specify one item, sometimes the item contains multiple files. For example, Windows Forms item templates can contain a code file, a designer file, and a resource file. For more information, see How to: Create Multi-file Item Templates.

  • An optional icon file to appear in the Add New Item dialog box.

Project template .zip files contain:

  • The .vstemplate file that contains the metadata for the template.

  • The project file or Web.config file.

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

  • An optional icon file to appear in the New Project dialog box.

Creating and Using Templates

Project and item templates are created and used in different ways. The following table explains how to complete common tasks with project and item templates.

Task

Project Templates

Item Templates

Specifying the template type in the .vstemplate file.

Set the Type attribute of the VSTemplate element to Project.

Set the Type attribute of the VSTemplate element to Item.

Instantiating the template.

Select the template from the New Project dialog box.

With a project open, select the template from the Add New Item dialog box.

Adding assembly references.

Add references to the project before creating the template.

Add references with the References element in the .vstemplate file.

See Also

Tasks

How to: Add References to Templates

Reference

Visual Studio Template Schema Reference

Other Resources

Visual Studio Templates

Creating Item Templates

Creating Project Templates