I'm creating a power shall scrip to run exe file with arguments. The list of args are constructed in a way that if value of the arg is empty or null, the parameter shall not be passed
Below is my script
$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
It looks like that PowerShell do a 'new line' before $runnerCommand in the last line of code that results in not passing the args from $runnerCommand
Please suggest how to solve the problem.
I tried different approaches