Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual Studio SDK
 How to: Specify a Language in Text ...
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Domain-Specific Language Tools 
How to: Specify a Language in Text Templates 

You can add a template directive to text templates and use that directive to specify the language that you want to use in your text template. For more information, see Directive Syntax (Domain-Specific Languages).

You can specify Visual C# or Visual Basic. The language that you specify declares the programming language used for code statements, expressions, and class features inside your text template.

NoteNote

The generated text output that the transformation process creates can be in any language, not necessarily the same language in which the text template is written. (The output language does not even have to be a programming language.)

To specify the language to use in a template

  1. In Solution Explorer, right-click the text template file that you want to specify a language for, and then click Open.

    The template opens in the text editor.

  2. At the top of the file, add a template directive, specifying VB for Visual Basic or C# for Visual C#. If your text template already contains a template directive, add the language parameter to the existing one. If the template directive contains multiple parameters, the order does not matter. You can add the language parameter to the beginning or the end of the template directive.

    Visual Basic
    <#@ template <b>language="VB"</b> debug="true" #>
    

    C#
    <#@ template debug="true" <b>language="C#"</b>#>
    
    NoteNote

    If the language parameter is omitted, the default language is Visual C#.

  3. Save the file.

    NoteNote

    To debug text templates, you must set the debug parameter of the template directive. For more information, see How to: Debug Text Templates.

Security

For more information, see Security of Text Templates.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker