Freigeben über


How to: Specify File Output Types in Text Templates

You can add an outputdirective to text templates. This output directive will indicate the type of file that you want the template to generate. For more information, see Directive Syntax (Domain-Specific Languages).

To specify the output file type in a text template file

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

    The template opens in the editor.

  2. Add an output directive to the template.

    In the following example, a .vb output file will be generated:

    <#@ output extension=".vb" #>
    

    Hinweis

    You can specify any appropriate file type extension (for example, .vb, .txt, .htm, and so on). If you do not use an output directive, the output file will have a .cs extension by default.

  3. Right-click the text template file, and click Run Custom Tool to generate the output file with the extension that you specified.

    Hinweis

    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

Concepts

Using Built-in Directives in Text Templates

Adding Code to Text Templates

Generating Artifacts Using Text Templates

Walkthrough: Creating and Running Text Templates