Thiago Loureiro
Thiago Loureiro

Reputation: 1143

Visual Studio Pre-Build Variables (TextTransform.exe)

I need to use TextTransform and I have currently this pre-build Event, which it's working:

"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\TextTransform.exe" -a !!BuildConfiguration!$(Configuration) "$(ProjectDir)Properties\AssemblyInfo.tt"

But I wanted to replace the \2019\Enterprise\ with variables according to the user version/edition, tried to google and search here but didn't found anything.

Upvotes: 0

Views: 931

Answers (2)

vycdev
vycdev

Reputation: 39

The macro $(MSBuildStartupDirectory) stated in OP's answer is wrong because this will return the directory of wherever msbuild is running, which is basically the project directory.

You can find the macro for the VS installation directory here: https://learn.microsoft.com/en-us/cpp/build/reference/common-macros-for-build-commands-and-properties?view=msvc-170

The macro is $(DevEnvDir)

So the final result would be:

"$(DevEnvDir)\TextTransform.exe"

Upvotes: 1

Thiago Loureiro
Thiago Loureiro

Reputation: 1143

Found a solution, in this link have some really useful varaibles:

Link to all Visual Studio $ variables

Then I'm using:

MSBuildStartupDirectory Which is:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE 

Result:

"$(MSBuildStartupDirectory)\TextTransform.exe" -a !!BuildConfiguration!$(Configuration) "$(ProjectDir)Properties\AssemblyInfo.tt"

Upvotes: 1

Related Questions