Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
 Differences Between Project and Ite...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual Studio 
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.

    NoteNote

    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

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Namespaces of project items can change depending on where the item is added      Craig Skibo - MSFT   |   Edit   |   Show History

When an item is added to a project, for some languages (such as C#) the $rootnamespace$ parameter can change depending on where the item is added. For example, if an item is added as a child of the project node, then the namespace of the item will be the default namespace set within the project properties. However, if an item is added to a folder within that node, the name of the folder will be added to the project's default namespace.

For example, suppose an item is added to the MyFolder2 node in the following project, and the project's default namespace is MyNamespace:

MyProject

    MyFolder1

        MyFolder2

 The namespace of the item added will be MyNamespace.MyFolder1.MyFolder2

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker