9

Where is TextTransform.exe located?

I'm trying to implement the solution in this post: Get Visual Studio to run a T4 Template on every build

However I'm getting an error

"'TextTransform.exe' is not recognized as an internal or external command, operable program or batch file."

I have been looking through the program files, however not sure where TextTransform.exe is located.

Community
  • 1
  • 1
Paul
  • 175
  • 2
  • 4

4 Answers4

6

It should be below

\Program Files\Common Files\Microsoft Shared\TextTemplating\

see: http://msdn.microsoft.com/en-us/library/bb126245.aspx

CaffGeek
  • 21,856
  • 17
  • 100
  • 184
  • Cool, thanks for the link Chad. I don't have VS2010, I have 2008. So the location for VS2008 is here: C:\Program Files\Common Files\Microsoft Shared\TextTemplating\1.2 – Paul Jul 26 '10 at 16:33
  • @Paul, same location here actually, which is why I took out the version from the URI – CaffGeek Jul 26 '10 at 17:08
  • 1
    for Visual Studio 2010 it is in %Program Files (x86)%\Common Files\Microsoft Shared\TextTemplating\10.0 – Lars Truijens Apr 29 '11 at 08:33
  • 4
    For 2017 CE its here: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\TextTransform.exe" – codingdave Jun 01 '17 at 10:01
  • Please refer to StingyJack s answer below regarding using vswhere.exe as it finds TextTransform.exe regardless of Visual Studio version. – strongbutgood Jun 03 '21 at 03:59
4

Anyone coming to this question that's using VS 2017 or later should be using vswhere to locate this file. @codingdave's comment is the closest but that still won't work on many computers.

I've added an example to the Microsoft Docs article feedback that shows how to do this with Powershell.

#the path to VSWhere.exe is always in programfiles(x86)

$progFilesx86Path = [System.Environment]::ExpandEnvironmentVariables("%programfiles(x86)%")
$vsWherePath = Join-Path $progFilesx86Path "\Microsoft Visual Studio\Installer\vswhere.exe"

# this tells vswhere to use paths of the latest version of visual studio installed 
# to locate this exe anywhere in those paths, and return a single textual 
# value (not a json object or xml payload)

$ttExe = & $vsWherePath -latest -find **\TextTransform.exe -format value
if (-Not(Test-Path $ttExe)){
    throw "Could not locate TextTransform.exe"
}

#then to invoke a transformation
& "$ttExe"  c:\Source\YourTransform.tt
halfer
  • 19,824
  • 17
  • 99
  • 186
StingyJack
  • 19,041
  • 10
  • 63
  • 122
  • This is useful in msbuild, I set up a property `<_vsWhereExe Condition="!Exists('$(_TransformExe)')">$(ProgramFiles)\Microsoft Visual Studio\Installer\vswhere.exe` then used an exec task to output to a _TransformExe property which could then be used in a before build target. My previous msbuild setup used a cascading probe of absolute paths... – strongbutgood Mar 16 '21 at 04:01
4

From @codingdave's comment
For VS2017, VS2019 location of TextTransform.exe will be

C:\Program Files (x86)\Microsoft Visual Studio\<<Version>>\<<Edition>>\Common7\IDE
Version -> (2017/2019/....)
Edition -> (Community/Professional/Enterprise)

And in pre build event we can use macro like
"$(DevEnvDir)\TextTransform.exe" "$(ProjectDir)AssemblyInfo.tt"

Palanikumar
  • 6,940
  • 4
  • 40
  • 51
0

I would recommend trying this over that solution: http://www.olegsych.com/2010/04/understanding-t4-msbuild-integration

If you don't have VS 2010, though, I suppose you're stuck doing it the hard way.

Aeka
  • 51
  • 1