Skip to content

Commit 3b95f38

Browse files
mattleibowCopilot
andauthored
Fix generate.ps1 error propagation (#3569)
- Replace Invoke-Expression with splatted args array ($runArgs) for proper exit code propagation — Invoke-Expression silently swallows non-zero exits - Continue through all projects to report ALL failures, then exit 1 - Use $LASTEXITCODE instead of $? for reliable native command error detection Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5a4a34b commit 3b95f38

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

utils/generate.ps1

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,31 @@ New-Item -ItemType Directory -Force -Path "output/generated/" | Out-Null
2626

2727
dotnet build utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj
2828

29+
$failed = $false
2930
foreach ($proj in $projects) {
3031
$json = $proj.Json;
3132
$output = $proj.Output;
3233
$root = $proj.Root;
3334
$filename = Split-Path $output -Leaf
3435

35-
$cmd = "dotnet run --no-build --no-launch-profile --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/$json --root $root --output binding/$output"
36-
Write-Host $cmd
37-
Invoke-Expression $cmd
38-
if (!$?) {
39-
exit $LASTEXITCODE
36+
$runArgs = @("run", "--no-build", "--no-launch-profile",
37+
"--project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj",
38+
"--", "generate",
39+
"--config", "binding/$json",
40+
"--root", $root,
41+
"--output", "binding/$output")
42+
Write-Host "dotnet $($runArgs -join ' ')"
43+
& dotnet @runArgs
44+
if ($LASTEXITCODE -ne 0) {
45+
Write-Host "ERROR: Generation failed for $json with exit code $LASTEXITCODE"
46+
$failed = $true
47+
continue
4048
}
4149

4250
Copy-Item -Path binding/$output -Destination output/generated/$filename -Force
4351
}
52+
53+
if ($failed) {
54+
Write-Host "ERROR: One or more generation steps failed"
55+
exit 1
56+
}

0 commit comments

Comments
 (0)