8

I am using a T4 template to (among other things) increment build numbers in the AssemblyInfo.cs file.

As I only want the transformation to occur when I run a Release build, I have previously done this by having the build action on the T4 file as being "None" and having a kludge of a pre-build command on the project of:

if $(Configuration) == Release "%CommonProgramFiles(x86)%\microsoft shared\TextTemplating\12.0\TextTransform.exe" -a !!build!true  "$(ProjectDir)Transforms\AssemblyInfo.tt"

I am now moving to VS2017 and I want to know if there are any better ways of doing this. Answers to questions like Get Visual Studio to run a T4 Template on every build basically offer:

  1. A souped up version of what I am already doing (but with batch files)
  2. Point to lots of VS extensions that try to run the T4 stuff on every build.
  3. Propose manually modifying the project file (which I don't want to do as 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 on a release build only, that integrates into the solution from the IDE and doesn't rely on batch files?

Another question Determine solution configuration (debug/release) when running a T4 template shows how to get the build type from within the T4 template, but by then it's too late for me.

Community
  • 1
  • 1
Peter M
  • 7,309
  • 3
  • 50
  • 91

0 Answers0