How to: Pass Custom Parameters to Templates 
This page is specific to:.NET Framework Version:
2.03.54
Visual Studio 
How to: Pass Custom Parameters to Templates 

You can use the CustomParameter element in your .vstemplate file to add new parameters to a template. For a complete list of template parameters, see Template Parameters.

To add a custom parameter

  1. Locate the TemplateContent element in the .vstemplate file for the template.

  2. Add a CustomParameters element and one or more CustomParameter child elements as children of the TemplateContent element. For example:

    <TemplateContent>
        ...
        <CustomParameters>
            <CustomParameter Name="$MyParameter1$" Value="MyValue2"/>
            <CustomParameter Name="$MyParameter2$" Value="MyValue2">
        </CustomParameters>
    </TemplateContent>
  3. Use the parameter in one or more of the code files in the template. For example:

    string Value1 = "$MyParameter1"
    string Value2 = "$MyParameter2"

    When a project is created from the template, the values set by the Value attributes of the CustomParameter elements corresponding to the parameters will replace the parameters in the code files.

See Also

Community Content

Typo in paragraph 3 above
Added by:Sixto
The code should look like:

string Value1 = "$MyParameter1$"
string Value2 = "$MyParameter2$"

end tag required
Added by:Veera Bagu
end tag required for <CustomParameter> tag

<CustomParameters>
<CustomParameter Name="$MyParameter1$" Value="MyValue2"/>
<CustomParameter Name="$MyParameter2$" Value="MyValue2"/>
</CustomParameters>
© 2010 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View