I was playing with Sitecore solution, project setup, and configuration, I faced a need to alter the code generation logic used in it. We use TDS for content synchronization as well as its code generation engine build on T4 text templates.
While T4 is great for code generation, it is not as straightforward to debug them as it might be expected. So let me describe how to do this.
How-To
I have a solution with a set of projects. Each TDS project is referencing to the templates in a central location.
To start debugging I would need the following:
- Start two instances of Visual Studio (in my case 2015) with the project containing T$ templates.
- Add debug=“true” to a template
|
|
On the TDS project that you using run “Regenerate Code for all items”
Debugger windows will appear as soon as code would hit “Debugger.Launch()” where you would need to select another instance of Visual Studio which runs your templates.
Done: Once the debugger loads itself - you are ready to dive into your code. Here is what you would be able to see in glassv3header.tt for example.
Follow me on Twitter @true_shoorik. I would be glad to discuss the ideas above in the comments.