3 out of 7 rated this helpful - Rate this topic

How to: Substitute Parameters in a Template 

You may replace template parameters such as class names and namespaces when a file based on a template is created. For a complete list of template parameters, see Template Parameters.

Procedure

You may replace parameters in the files of a template whenever a project based on that template is created. This procedure explains how to create a template that replaces the name of a namespace with the safe project name when a new project is created with the template.

To use a parameter to replace namespace name with the project name

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

    namespace $safeprojectname$
    
    NoteNote

    Template parameters are written in the format $parameter$.

  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. For example:

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

See Also

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
question: how can pass the connection string to template?
I found a lot of topic about sending the parameters like namespace to template in visual studio. $0But my problem is how can I get the connection string from user and pass it to template, during adding the template that is provided before?$0 $0$0 $0 $0thanks$0 $0$0 $0
Advertisement