How do I get a T4 template to generate its output on every build? As it is now, it only regenerates it when I make a change to the template.
I have found other ques
The pre-build can be reduced to a single line:
forfiles /p "$(ProjectDir)." /m "*.tt" /s /c "cmd /c echo Transforming @path && \"%CommonProgramFiles(x86)%\Microsoft Shared\TextTemplating\1.2\TextTransform.exe\" @file"
This transforms all .tt
files in the project and lists them to the build output.
If you don't want the build output then you have to work around some "interesting behaviour":
forfiles /p "$(ProjectDir)." /m "*.tt" /s /c "cmd /c @\"%CommonProgramFiles(x86)%\Microsoft Shared\TextTemplating\1.2\TextTransform.exe\" @file"
Of course, you can pull this out into a batch file to which you pass the project directory path if you wish.
NB The path may require some tweaking. The path above is where VS 2008 installed it on my machine; but you might find that the version number between TextTemplating
and TextTransform.exe
is different.