Repository navigation
Propagate dotnet.exe exit code from eng/common/dotnet.ps1 - #7214
Conversation
When a CI step invokes `eng/common/dotnet.cmd build ...` on Windows (e.g. signing validation), a non-zero exit from dotnet.exe is silently dropped: the chain is pwsh -> dotnet.cmd -> powershell.exe -> dotnet.ps1 -> dotnet.exe. dotnet.ps1's last statement is a native invocation `& "$dotnetRoot\dotnet.exe" $args`, with no `exit $LASTEXITCODE`, so the spawned powershell.exe exits 0 even when dotnet.exe returned 1. dotnet.cmd then reports `%ErrorLevel%` = 0 and the outer pwsh step is marked green even though the build failed. dotnet.sh is unaffected because bash propagates the last command's exit status by default. Call `ExitWithExitCode $LASTEXITCODE` after invoking dotnet.exe so the exit code surfaces to callers, matching the convention already used by the other eng/common/*.ps1 scripts (msbuild.ps1, sdk-task.ps1, build.ps1, dotnet-install.ps1, etc). Apply the same change to the mirrored copy at eng/common/dotnet.ps1 so the fix takes effect in the VMR immediately; per-repo eng/common copies under src/*/eng/common/ will pick this up via arcade code flow. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR aims to ensure Windows CI correctly fails when eng/common/dotnet.cmd invokes dotnet.exe and dotnet.exe returns a non-zero exit code, aligning behavior with macOS/Linux where the exit status is naturally propagated.
Changes:
- Add
ExitWithExitCode $LASTEXITCODEafter invokingdotnet.exeinsrc/arcade/eng/common/dotnet.ps1. - Add the same exit-code propagation logic in the VMR copy
eng/common/dotnet.ps1.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/arcade/eng/common/dotnet.ps1 | Adds explicit exit-code propagation after running dotnet.exe. |
| eng/common/dotnet.ps1 | Mirrors the same change in the VMR top-level copy so pipelines pick it up immediately. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Behavior-change analysisI audited all callers of There is one class of callers worth flagging explicitly: in-process Identified in-process callers in the VMR:
For the four F# scripts, the prior behavior was that a failed For arcade's I don't think any of these need changes alongside this PR — they were all latent bugs that this fix now surfaces correctly. Flagging in case reviewers want to weigh in. |
|
/backport to release/10.0.1xx |
|
Started backporting to |
When a CI step invokes
eng/common/dotnet.cmd ...on Windows (e.g. signing validation), a non-zero exit fromdotnet.exeis silently dropped and the step is marked green even when the build failed. Reproduces in #6019: on Mac/Linux, a failingdotnet buildcorrectly fails the AzDO step (yellow withcontinueOnError: true); on Windows the same failure shows as green ✓.Root cause
On Windows the invocation chain is:
dotnet.ps1:When
dotnet.exereturns 1:$LASTEXITCODEinsidedotnet.ps1is 1.exit $LASTEXITCODE, so the spawnedpowershell.exeexits 0.dotnet.cmdreads%ErrorLevel%(= 0 from thepowershell.execall) and doesexit /b 0.dotnet.shis unaffected because bash propagates the last command's exit status by default.Fix
Call
ExitWithExitCode $LASTEXITCODEafter invokingdotnet.exe, matching the convention already used by the othereng/common/*.ps1scripts that invoke native tools (msbuild.ps1,sdk-task.ps1,build.ps1,dotnet-install.ps1, etc.).Patched in two places:
src/arcade/eng/common/dotnet.ps1— the upstream-flowing source of truth.eng/common/dotnet.ps1— the VMR top-level copy, so the fix takes effect in VMR pipelines immediately. Per-repo copies undersrc/*/eng/common/will pick this up via arcade code flow.