Dijeli putem


How to: Substitute parameters in a template

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Template parameters let you replace identifiers such as class names and namespaces when a file is created from a template. You can add template parameters to existing templates, or create your own templates with template parameters.

Template parameters are written in the format $parameter$. For a complete list of template parameters, see Template parameters.

The following section shows you how to modify a template to replace the name of a namespace with the "safe project name".

Example - namespace name

  1. Insert the parameter in one or more of the code files in the template. For example:

    namespace $safeprojectname$
    
  2. In the vstemplate file for the template, locate the ProjectItem element that includes this file.

  3. Set the ReplaceParameters attribute to true for the ProjectItem element:

    <ProjectItem ReplaceParameters="true">Class1.cs</ProjectItem>
    

See also