Muokkaa

Jaa


What are project and item templates?

Project and item templates are reusable stubs that give you some basic code and structure to customize for your own purposes. Typically, you start with a project template and then you add an item template.

Visual Studio templates

There are many predefined project and item templates available to you when you install Visual Studio. Project templates, such as the ASP.NET Core Web App and Class Library templates, are available to choose from when you create a new project. Item templates, such as code files, XML files, HTML pages, and Style Sheets, appear in the Project > Add New Item dialog box.

These templates provide a starting point for users to begin creating projects, or to expand existing projects. Project templates provide the files that are required for a particular project type, include standard assembly references, and set default project properties and compiler options. Item templates can range in complexity from a single empty file that has a specific file extension, to multiple source code files with stub code, designer information files, and embedded resources.

You can use installed templates, author your own custom templates, or download and use templates created by the community. For more information, see How to: Create project templates and How to: Create item templates.

Contents of a template

All project and item templates, whether installed with Visual Studio or created by you, function by using the same principles and have similar contents. All templates contain the following items:

  • The files to be created when the template is used. These files include source code files, embedded resources, project files, and so on.

  • A .vstemplate file, which contains the metadata needed to create a project or item from the template and to display the template on the Create a new project page or in the Add New Item dialog box.

    For more information about .vstemplate files, see Template tags and Template parameters.

When these files are compressed into a .zip file and put in the correct folder, Visual Studio automatically displays them in the following places:

  • Project templates appear on the Create a new project page.

  • Item templates appear in the Add New Item dialog box.

For more information about template folders, see How to: Locate and organize project and item templates.