使用Powershell中的参数运行TextTransform.exe

问题描述:

我想在PowerShell v3中使用模板上的参数args运行TextTransform.exe。这里是我的变数和我尝试的选项。请注意,它没有'-a'参数,但我需要参数才能正确运行模板。使用Powershell中的参数运行TextTransform.exe

$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 

希望这有助于别人。