I use the T4 template to (among other things) build build numbers in the AssemblyInfo.cs file.
As soon as I want the transformation to happen when I run the Release build, I previously did this by creating the build action in the T4 file as "None" and having the kludge of the pre-build command in the of project:
if $(Configuration) == Release "%CommonProgramFiles(x86)%\microsoft shared\TextTemplating\12.0\TextTransform.exe" -a !!build!true "$(ProjectDir)Transforms\AssemblyInfo.tt"
Now I am switching to VS2017 and I want to know if there are any better ways to do this. Answers to questions such as Get Visual Studio to run the T4 template in each assembly basically offer:
- Existing version of what I'm already doing (but with batch files)
- Specify the number of VS extensions that try to run T4 stuff in each assembly.
- We suggest manually modifying the project file (which I do not want to do, because it makes the process invisible when using the IDE)
In 2017, is there a better approach in VS2017 to what I want to do? Something allows me to run my T4 only to build a release that integrates into the solution from the IDE and does not rely on batch files?
Another question Determining the solution configuration (debug / release) when starting the T4 template shows how to get the build type from the T4 template, but by then it is too late for me.
source
share