Compartilhar via


Diferenças Entre Modelos de Projeto e de Item

Visual Studiomodelos são divididos em duas categorias principais: os modelos de projeto e modelos de item. 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 Como: Usar assistentes com modelos de projeto.

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.

    ObservaçãoObservação

    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 Como: Criar modelos de Item multiarquivos.

  • 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.

Consulte também

Tarefas

Como: Adicionar referências para modelos

Referência

Referência de esquema de modelo do Studio Visual

Outros recursos

Modelos Visual Studio

Criando modelos de item

Criando modelos de projeto