How to programmatically control the Build Action of the new files generated from a T4?
The question is: is there a way to have a setting in the *.tt file so that the generated files are set to a specified Build Action?
The thing is I am generating code using a template, but it only meant to be a starting point, eliminating a lot of typing. I do not want anyone to use the code(generated classes) as is, nor I want it to clutter the namespace. Currently, I have to manually set th开发者_运维问答e Build Action to None every time a new file being added by the template - I would like to automate it.
Thank you!
A very simple workaround is to wrap the generated code into an #if
statement:
#if GENERATED_CODE
// my generated code
// will compile only if the variable GENERATED_CODE is defined
#endif
精彩评论