我想在 PowerShell v3 中使用模板上的参数 args 运行 TextTransform.exe。这是我的变量和我尝试过的选项。请注意,它无需使用“-a”参数,但我需要参数才能正确运行模板。
$textTransformPath = "C:\Program Files (x86)\Common Files\Microsoft Shared\TextTemplating\14.0\TextTransform.exe"
$templateath = "$ProjectPath\TheTemplate.tt"
$textTransformParams = "-a !!TheParam!$TheValue"
#& "$textTransformPath" "$templatePath" <-- this runs, but no args!
# these don't work:
& "$textTransformPath" "$templatePath" $textTransformParams
& "$textTransformPath" "$templatePath" "$textTransformParams"
我不知道为什么这么难,看起来应该很容易。如果我在标准命令行中输入此内容,它就会起作用,这验证了问题出在我的 PS 语法上。
最佳答案
它永远不会失败......几乎放弃后的最后一次搜索找到了答案:
Using $(SolutionDir) when running template via TextTransform.exe
我之前显然没有尝试过的组合是:
& "$textTransformPath" "$templatePath" -a !!TheParam!$TheValue
希望这对其他人有帮助。
关于powershell - 从 Powershell 运行带参数的 TextTransform.exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40667764/