fix: check MSBuild exit code instead of stderr for project cracker failure detection#4564
Merged
MangelMaxime merged 1 commit intomainfrom Apr 26, 2026
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated PR from Repo Assist.
Closes #4562
Root Cause
In
MSBuildCrackerResolver.fs, thedotnet_msbuild_with_defineshelper checked whetherstderrwas non-empty to determine if the MSBuild invocation failed: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 thoughdotnet buildwould succeed with the same project.Fix
Replace the stderr-content check with an exit-code check:
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.