TextTransform.exe位于硬盘上的哪个位置?

Pau*_*aul 6 t4

TextTransform.exe在哪里?

我正在尝试在这篇文章中实现解决方案: 让Visual Studio在每个构建上运行T4模板

但是我收到了一个错误

"'TextTransform.exe'无法识别为内部或外部命令,可操作程序或批处理文件."

我一直在查看程序文件,但不确定TextTransform.exe的位置.

Caf*_*eek 6

它应该在下面

\Program Files\Common Files\Microsoft Shared\TextTemplating\
Run Code Online (Sandbox Code Playgroud)

请参阅:http://msdn.microsoft.com/en-us/library/bb126245.aspx

  • 对于 2017 CE,这里是:“C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\TextTransform.exe” (3认同)

Sti*_*ack 5

任何使用 VS 2017 或更高版本来回答此问题的人都应该使用 vswhere 来查找此文件。@codingdave 的评论是最接近的,但在许多计算机上仍然不起作用。

我已在Microsoft Docs 文章反馈中添加了一个示例,该示例展示了如何使用 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
Run Code Online (Sandbox Code Playgroud)


Pal*_*mar 5

来自@codingdave评论
对于 VS2017,TextTransform.exe 的 VS2019 位置将是

C:\Program Files (x86)\Microsoft Visual Studio\<<Version>>\<<Edition>>\Common7\IDE
版本 -> (2017/2019/....)
版本 -> (社区/专业/企业)

在预构建事件中我们可以使用类似的宏
"$(DevEnvDir)\TextTransform.exe" "$(ProjectDir)AssemblyInfo.tt"