Skip to content

Commit 7a4ee2a

Browse files
committed
build: fix build.ps1 argument parsing and passing
Switches should not have values and some keys' values should not be enclosed with double-quotes. Both were leading to fatal errors.
1 parent 3b25350 commit 7a4ee2a

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

build.ps1

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,30 @@ $Arguments = @{
4343
exclusive=$Exclusive;
4444
nuget_useinprocessclient=$true;
4545
}.GetEnumerator() | ForEach-Object {
46-
if ($_.value -ne "") { "--{0}=`"{1}`"" -f $_.key, $_.value }
46+
if ($($_.Key -ceq "dryrun") -or ($_.Key -ceq "exclusive")) {
47+
if ($_.Value -eq $true) {
48+
# switches must not be assigned true or false, but must be passed to indicate true.
49+
"--{0}" -f $_.Key
50+
}
51+
}
52+
else {
53+
if ($_.Value -cne "") {
54+
if ($_.Value -as [string] -contains " ") {
55+
$_.Value = "$($_.Value)" # if it contains spaces, enclose it.
56+
}
57+
"--{0}={1}" -f $_.Key, $_.Value
58+
}
59+
}
4760
};
4861

62+
$Arguments | Join-String -Separator " " | Write-Verbose
63+
4964
# Start Cake
5065
Write-Host "Running build stage $Stage..."
5166

52-
& dotnet run --project build/$Stage/$Stage.csproj -- $Arguments $ScriptArgs
67+
$cmdline = "& dotnet run --project build/$Stage/$Stage.csproj -- $Arguments $ScriptArgs"
68+
Write-Verbose $cmdline
69+
Invoke-Command -ScriptBlock ([scriptblock]::Create($cmdline))
5370

5471
if ($env:APPVEYOR) {
5572
$host.SetShouldExit($LASTEXITCODE)

0 commit comments

Comments
 (0)