开发者

Debug tt templates in VS2008

开发者 https://www.devze.com 2022-12-13 10:29 出处:网络
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 T开发者_运维知识库ool\'.Here is an e

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 T开发者_运维知识库ool'.


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().)


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
  • ...


Start your template with:

<#@ template debug="true" ...

and add:

System.Diagnostics.Debugger.Break();

to your template code to break into the compiled generator class.

0

精彩评论

暂无评论...
验证码 换一张
取 消