Emit Warning When Using CLI Switches from Auto-Response File Lead to Errors#13675
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves MSBuild CLI diagnostics by emitting the existing “picked up switches from auto-response file” notice before reporting a command-line switch error, so users can more easily identify when an auto-response file (e.g., Directory.Build.rsp) contributed to the failure.
Changes:
- Print response-file pickup notices when a
CommandLineSwitchExceptionis caught (so the notice appears even when parsing fails early). - Add a unit test covering the “project specified both in
Directory.Build.rspand on the command line” (MSB1008) scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/MSBuild/XMake.cs | Prints response-file notices in the switch-error handler and factors the printing into a helper method. |
| src/MSBuild.UnitTests/XMake_Tests.cs | Adds a regression test verifying the notice is present when a switch error occurs with Directory.Build.rsp. |
This was referenced May 4, 2026
rainersigwald
approved these changes
May 14, 2026
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.
Fixes #3789
Context
Currently, if there is a directory.build.rsp with one project specified and then MSBuild is invoked passing a different project through CLI, MSBuild prints an error message:
MSBUILD : error MSB1008: Only one project can be specified.However, there is no indication what is the second project for the user. In MSBuild, there is a warning already implemented which satisfies this. However, it is not printed early enough for this specific scenario. It would be beneficial if the warning would be printed before the error, so the user knows where is the second project specified
Changes Made
XMake.cs
Added a line which emits this warning before the error so the user is notified. The warning used is the one that is already implemented in the MSBuild.
Some command line switches were read from the auto-response file "MSBuild.rsp". To disable this file, use the "/noautoresponse" switch.Testing
XMake_Tests.cs
Added a unit tests for this scenario.