T4 Templates: Any way to get a template to start when any class that it uses is changed?

I created a simple development-time pattern that uses an enumeration that resides in the same project. The template defines the class definition for each variable in this type of enumeration.

I noticed that modifying and saving the .tt file in any case causes it to deflate the C # code again. I hope that I can establish the solution so that if I change the enumeration and then save, then the template can also start the source again. That way, when I want to add a new type, I could add a variable to the enum definition and maybe just click save.

At the moment, I have to do this:

  • Add a variable to the enumeration definition in the .cs file.
  • Compile the project.
  • Run the "run custom tool" in the .tt file. template.
  • then you need to compile the compilation again in the source created by t4.

So, maybe there is a way to make the pattern “detect” a change in another source using what it uses, and act as if it were changed by itself?

+5
source share
1 answer
  • Start by installing the T4 Toolbox . It adds many features that make working with T4 files easier.

  • Custom Tool .cs T4ScriptFileGenerator. .tt .cs. ( Oleg Sych, T4, ). , .cs, T4 Toolbox .tt.

  • , . , , , . Visual Studio EnvDTE, enum. # IDE .

+3

All Articles