Is there a way to debug tt files? I have installed SubSonic3 and all the templates do their job except the StoredProcedures.tt. It remains empty after 'Run Custom Tool'.
+2
A:
Start your template with:
<#@ template debug="true" ...
and add:
System.Diagnostics.Debugger.Break();
to your template code to break into the compiled generator class.
codekaizen
2009-12-03 07:53:30
Thx, thx, thx, will check this.
Lieven Cardoen
2009-12-03 10:54:19
This craches Visual Studio. At least it crashes mine. I suppose because there are no debuggers attached to Visual Studio process. I've found this on the net: "Note, if you are using Windows Vista or 2008 Server, this technique (using Debugger.Break()) can hang Visual Studio". http://www.olegsych.com/2008/09/t4-tutorial-debugging-code-generation-files/
Robert Koritnik
2009-12-11 08:39:02
I'm using VS2010 Beta 2. It doesn't crash.Check the video here: http://channel9.msdn.com/posts/VSIPMarketing/VSX206-Code-Generation-with-T4/ @ 25:45 for a demo.
codekaizen
2009-12-13 19:29:07
+2
A:
Read this article that will explain the use of both:
- JIT debugger (by placing
Debugger.Break()
in your template code) and - Manually attaching to Visual Studio process with the second instance of Visual Studio
The second one is useful to users of systems after Windows XP:
- Vista
- 7
- Server 2008
- Server 2008 R2
- ...
Robert Koritnik
2009-12-11 08:43:48
+2
A:
Here is an easy method.
Add lines like this one to your T4 code:
System.Diagnostics.Debug.WriteLine("This is a debug message.");
Download and run DebugView from Sysinternals. Your debug messages will appear in the output window.
(Behind the scenes, these calls use win32 OutputDebugString().)
dangph
2009-12-23 09:14:00