Skip to content

fix: check MSBuild exit code instead of stderr for project cracker failure detection#4564

Merged
MangelMaxime merged 1 commit intomainfrom
repo-assist/fix-issue-4562-nu1605-warning-compile-failure-c3160c1e0708118e
Apr 26, 2026
Merged

fix: check MSBuild exit code instead of stderr for project cracker failure detection#4564
MangelMaxime merged 1 commit intomainfrom
repo-assist/fix-issue-4562-nu1605-warning-compile-failure-c3160c1e0708118e

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated PR from Repo Assist.

Closes #4562

Root Cause

In MSBuildCrackerResolver.fs, the dotnet_msbuild_with_defines helper checked whether stderr was non-empty to determine if the MSBuild invocation failed:

if not (String.IsNullOrWhiteSpace error) then
    failwithf $"In %s{psi.WorkingDirectory}:\n%s{fullCommand}\nfailed with\n%s{error}"

MSBuild (and NuGet during restore) writes warnings to stderr even when the build succeeds (exit code 0). For example, NU1605 (package downgrade detected) is a warning that is printed on stderr but does not cause a build failure. The old check treated any stderr output as a fatal error, preventing compilation even though dotnet build would succeed with the same project.

Fix

Replace the stderr-content check with an exit-code check:

if ps.ExitCode <> 0 then
    failwithf $"In %s{psi.WorkingDirectory}:\n%s{fullCommand}\nfailed with\n%s{error}"

This is the standard pattern for determining whether a process failed. When MSBuild exits with a non-zero exit code (actual errors), the error message still includes the stderr output for diagnostics. When it exits with 0 (success, even with warnings), compilation proceeds normally.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@51c8f6ad4357d2ecc06e47120031b3d75e80227d

…tection

Previously, the MSBuild cracker would fail if there was any output on
stderr, even if the process exited successfully (exit code 0). This
caused NuGet warnings like NU1605 (package downgrade detected) to be
treated as fatal errors, preventing compilation even when dotnet build
would succeed.

Fix: check ps.ExitCode <> 0 to determine failure, rather than checking
for non-empty stderr. Warnings written to stderr no longer cause a
spurious compile failure.

Fixes #4562

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation Automated changes repo-assist Created by Repo Assist labels Apr 25, 2026
@MangelMaxime MangelMaxime marked this pull request as ready for review April 26, 2026 18:05
@MangelMaxime MangelMaxime changed the title [Repo Assist] fix: check MSBuild exit code instead of stderr for compile failure detection fix: check MSBuild exit code instead of stderr for compile failure detection Apr 26, 2026
@MangelMaxime MangelMaxime changed the title fix: check MSBuild exit code instead of stderr for compile failure detection fix: check MSBuild exit code instead of stderr for project cracker failure detection Apr 26, 2026
@MangelMaxime MangelMaxime merged commit 914a616 into main Apr 26, 2026
8 checks passed
@MangelMaxime MangelMaxime deleted the repo-assist/fix-issue-4562-nu1605-warning-compile-failure-c3160c1e0708118e branch April 26, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automated changes repo-assist Created by Repo Assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate: Fable fails to compile when there is a NU1605 waring

1 participant