Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log to output window when using T4

Tags:

.net

t4

I'm using T4 for code generation. Its working well but one thing I'd like to do is some simple logging, I'm happy if this simply took the form of throwing messages into the Output window.

Does anyone know a way of doing this?

Alternatively, I know there exists Error() & Warning() methods for dumping stuff into the Error List pane, is there anything similar for dumping informational messages?

like image 911
jamiet Avatar asked Oct 03 '14 07:10

jamiet


People also ask

How do I write to the Output window in Visual Studio?

You can write run-time messages to the Output window using the Debug class or the Trace class, which are part of the System. Diagnostics class library. Use the Debug class if you only want output in the Debug version of your program. Use the Trace class if you want output in both the Debug and Release versions.

How do I debug my T4?

To debug a design-time text template, save the text template file, and then choose Debug T4 Template on the shortcut menu of the file in Solution Explorer. To debug a run-time text template, simply debug the application to which it belongs.


1 Answers

It's not exactly what you asked for but you can debug a T4 template from within visual studio, just right click "Debug T4 Template".

If you do this it's easy enough to keep the state you would be sending to the output window in a variable somewhere.

like image 73
aboy021 Avatar answered Sep 28 '22 12:09

aboy021