How to programmatically control the action of assembling new files created using T4?

Question: is there a way to set the parameter in the * .tt file so that the generated files are configured for the specified assembly action?

The fact is that I generate code using a template, but this only means a starting point that excludes a lot of typing. I don’t want anyone to use the code (generated classes) as is, and I don’t want it to clutter the namespace. Currently, I have to manually set the Build Action to None every time a new file is added by the template - I would like to automate it.

Thanks!

+7
source share
1 answer

A very simple way to wrap generated code in the #if statement:

 #if GENERATED_CODE // my generated code // will compile only if the variable GENERATED_CODE is defined #endif 
0
source

All Articles