locked
How do you debug a T4 text template in visual studio 2010 without break point function? RRS feed

  • Question

  • How do you debug a T4 text template in visual studio 2010 without break point function?

    after installing t4 tools and tangible t4 editor

    when i try T4 text template, there is output error when right click run custom tool.

    but open text template, there can not be set break point to see where is wrong?

     

    when i move code from text template to cs code, there is no microsoft.visualstudio.uml.extension in reference.

    are there any ways to debug a text template to generate code?


    Hello
    Monday, June 6, 2011 8:18 AM

Answers

  • Take a look at Troubleshooting T4 Text Templates and its subtopics. Key points:

    To debug errors that occur when the text template code is executing, you can step through the code. To do this, you must add two lines to your template:

     

    • <#@template debug="true"#>

      If the template already contains a template directive, set the debug attribute in that directive.

    • <# System.Diagnostics.Debugger.Launch(); #>

      Insert this call near the beginning of the template code. When it is executed, you will be invited to debug the template using a new instance of Visual Studio. In this new instance, you can step through the template code using the F10 key.

    • If you want to re-enter the debugger later in the code, insert:

      <# System.Diagnostics.Debugger.Break(); #>


    - Alan -MSFT
    Wednesday, June 8, 2011 9:50 PM