I am trying to pass property through command line parameter ($args[0]) as follows using Powershell , but it is not being considered.
if ( Test-path -path $args[0]) {
&"$MsbuildBinPath\Msbuild.exe" $MSBuildFile /t:BuildAll "/p:AllComponents=$args[0]" $Logger $ErrorLogger
if ($LastExitCode -ne 0) {
Write-Host "It failed, send a mail"
}
}
If i pass the property like this follows, it is being considered.
"/p:AllComponents=List.txt"
Why command line arguments are not being considered when it applied directly?
I can store the command line value in some variable and pass but is there any other mechanism to pass it directly?
$args[0] is not expanded inside strings, you need to enclose it in a sub-expression notation:
To avoid this syntax, assign the argument to a variable and embed the variable in the string:
For more information, type the following in your console: