-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix NoWarn ignored when MSBuildWarningsAsMessages is set #12828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hello @@copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
Co-authored-by: JanProvaznik <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes issue #12808 where the NoWarn property was being ignored when MSBuildWarningsAsMessages was already set. The fix modifies Microsoft.Common.CurrentVersion.targets to unconditionally append $(NoWarn) to $(MSBuildWarningsAsMessages) instead of only setting it when MSBuildWarningsAsMessages is empty.
Key Changes:
- Changed the property assignment from conditional to unconditional append in
Microsoft.Common.CurrentVersion.targets - Added two end-to-end tests that import Common targets to verify both the bug fix and backward compatibility
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Tasks/Microsoft.Common.CurrentVersion.targets | Modified line 669 to always append $(NoWarn) to $(MSBuildWarningsAsMessages) using semicolon concatenation, removing the conditional check that prevented this when MSBuildWarningsAsMessages was already set |
| src/Build.UnitTests/WarningsAsMessagesAndErrors_Tests.cs | Added two test methods: one verifying that NoWarn is honored when MSBuildWarningsAsMessages is already set (the bug fix), and another ensuring the original behavior is preserved when MSBuildWarningsAsMessages is not set |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
@copilot ensure that there are tests that cover duplicate diagnostic code handling - now that |
Co-authored-by: baronfel <[email protected]>
Added Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Fixes #12808
Context
When a project sets both
MSBuildWarningsAsMessages(e.g.,NU1701) andNoWarn(e.g.,NETSDK1233),NoWarnis ignored because the targets only setMSBuildWarningsAsMessagesfrom$(NoWarn)whenMSBuildWarningsAsMessagesis empty.Changes Made
Microsoft.Common.CurrentVersion.targetsto always append$(NoWarn)to$(MSBuildWarningsAsMessages):NoWarnHonoredWhenMSBuildWarningsAsMessagesIsSetViaTargets: Verifies NoWarn is honored when MSBuildWarningsAsMessages is already setNoWarnWorksWhenMSBuildWarningsAsMessagesIsNotSetViaTargets: Ensures original behavior is preserved when MSBuildWarningsAsMessages is not setDuplicateDiagnosticCodesInNoWarnAndMSBuildWarningsAsMessagesAreHandled: Verifies that duplicate diagnostic codes (when the same code appears in both NoWarn and MSBuildWarningsAsMessages) are handled correctlyTesting
WarningsAsMessagesAndErrorstests passNoWarnhonored whenMSBuildWarningsAsMessagesis set, original behavior preserved when it's not, and duplicate diagnostic codes are handled correctlyNotes
The leading semicolon when
MSBuildWarningsAsMessagesis initially empty (producing;NAT013) is correctly handled bySemiColonTokenizer, which discards empty segments. This pattern is consistent with other property appending in the targets (e.g.,AssemblySearchPaths).💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.