Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you display the code (not output) that .Net T4 generates?

We have a set of T4 templates we have just migrated forward to VS 2010 and they compile but are no longer working the same.

In order to see what is actually going on under the hood it would be useful to see the temporary cs files that T4 generates to produce the actual T4 conversion.

like image 279
Gone Coding Avatar asked Jul 14 '11 13:07

Gone Coding


Video Answer


2 Answers

As you're now using Visual Studio 2010, you can also change the custom tool on the template from TextTemplatingFileGenerator to TextTemplatingFilePreprocessor temporarily.

This will spit out the underlying code directly into your project instead of the regular template output.

like image 151
GarethJ Avatar answered Sep 20 '22 05:09

GarethJ


If you set

<#@ template  debug="true"#>

then the generated code will be left in your temp directory. On my Windows 7 system, that's C:\Users\John Saunders\AppData\Local\Temp.

like image 41
John Saunders Avatar answered Sep 22 '22 05:09

John Saunders