【发布时间】:2022-11-11 20:47:33
【问题描述】:
我正在创建一个 powershell 脚本来运行带有参数的 exe 文件。 args 列表的构造方式是,如果 arg 的值为空或 null,则不应传递参数
下面是我的脚本
$runnerCommand = " "
[string]$splitRun = "20:1"
[string]$maxTestWorkers = "777"
[string]$retryTimes = "9"
[string]$testFilterInXmlFormat = "<filter><cat>XX</cat></filter>"
#$runnerCommand += '--testDllPath ' + $testDllPath + " "
if ($splitRun){
$runnerCommand+= "--splitRun '$splitRun' "
}
if ($maxTestWorkers){
$runnerCommand+= "--maxTestWorkers '$maxTestWorkers' "
}
if ($retryTimes){
$runnerCommand+= "--retryTimes '$retryTimes' "
}
if ($testFilterInXmlFormat){
$runnerCommand+= "--testFilterInXmlFormat '$testFilterInXmlFormat' "
}
$cmdPath = "C:\AutoTests\TestAutomation.Runner\bin\Debug\TestAutomation.Runner.exe"
& $cmdPath --testDllPath C:/AutoTests/Build/TestAutomation.TestsGUI.dll $runnerCommand
看起来 PowerShell 在最后一行代码的 $runnerCommand 之前做了一个“新行”,导致没有从 $runnerCommand 传递参数
请建议如何解决问题。
我尝试了不同的方法
【问题讨论】:
标签: powershell