Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual Studio SDK
 How to: Debug Text Templates
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: Debug Text Templates 

One of the common uses for domain-specific languages is to generate code and other artifacts from models. Domain-Specific Language Tools use text templates to generate code, xml, reports, or other artifacts from models. A text template is a file containing a mixture of text blocks and control logic used to combine the text blocks with the data held within a model to produce an output file.

To enable debugging, set the debug parameter of the template directive, as explained in the following procedure.

To set the debug parameter of the template directive

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

    The template opens in the editor.

  2. Add the following template and import directives to the template:

    <#@ template debug="true" #>
    <#@ import namespace="System.Diagnostics" #>

    The template directive contains a debug parameter, and we have set the parameter to true. Setting the debug parameter to true causes the engine to add the underlying source and .pdb files needed to enable debugging.

  3. Insert a Debugger.Break statement in the text template where you want to insert a breakpoint as shown below:

    C#
    <# Debugger.Break(); #>
    

    Visual Basic
    <# Debugger.Break() #>
    

  4. In Solution Explorer, in the project node, right-click the text template file and click Run Custom Tool.

    The break statement will execute and you will either be prompted for a debugging session or be taken to the applicable line of code.

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