Repository navigation
Raise NU1701 for every target framework - #7845
Merged
zivkan merged 1 commit intoNov 4, 2026
Merged
Conversation
LockFileBuilder kept one set of libraries that already had the warning for the whole project, so only the first framework in the project got it. The set is now per target alias, which still avoids repeating the warning for RID graphs. Aliases of the same framework produce the same text, so those are merged into one message with both target graphs.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change to framework-specific NU1701 warning reporting.
No open issues 🎉
What changed in this PR
This PR fixes NU1701 reporting during restore so that a warning suppressed for one target framework no longer hides warnings for other frameworks.
Changes:
- Track fallback warnings per target alias and library, while avoiding duplicates for runtime-specific graphs.
- Merge identical warning messages across aliases of the same framework.
- Enable and extend regression coverage for multiple frameworks, framework-specific suppression, runtime identifiers, and aliases.
| File | Description |
|---|---|
test/NuGet.Core.FuncTests/NuGet.Commands.FuncTest/RestoreCommandTests.cs |
Enables multi-framework coverage and adds suppression and runtime-graph tests. |
test/NuGet.Core.FuncTests/NuGet.Commands.FuncTest/RestoreCommand_Aliases.cs |
Restores the assertion that both aliases appear in warning target graphs. |
test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetRestoreTests.cs |
Restores the equivalent alias assertion in CLI integration coverage. |
src/NuGet.Core/NuGet.Commands/RestoreCommand/LockFileBuilder.cs |
Scopes warning deduplication by alias and merges collected warnings before logging. |
Review effort: Balanced
jeffkl
approved these changes
Nov 2, 2026
nkolev92
approved these changes
Nov 4, 2026
zivkan
approved these changes
Nov 4, 2026
This was referenced Nov 4, 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.
Bug
Fixes: NuGet/Home#14815
Description
LockFileBuilderkeptlibrariesWithWarningsfor the whole project, so once a library had NU1701 for the first framework, no other framework got it. This also hid the warning completely in one case: withNoWarnon the package fornet10.0, the warning was raised fornet10.0and suppressed, andnet9.0never got one.The set now tracks
(TargetAlias, library), so each framework is checked, and RID graphs of the same framework still don't repeat the warning. The messages are collected and logged after the target loop through the existingDiagnosticUtility.MergeOnTargetGraph, so aliases of the same framework become one message with both target graphs.One thing to check, because it differs from the skipped test.
RestoreCommand_WithAssetTargetFallbackFromProject_WarningsRaisedWhenApplicableexpected one message with two target graphs fornet10.0andnet9.0. The text of NU1701 names the framework (instead of the project target framework '{2}'), so one message would be wrong for one of the two. I went with one message per framework and changed the test to expect two. Aliases of the same framework have the same text and do merge, which is what the commented out assertion inRestoreCommand_Aliasesexpected.If you'd rather have a single message, the text would need to list the frameworks, for example by joining them the way
GetFallbackFrameworkStringdoes. ANoWarnon one framework would then leave a message that still names it. I can change it if you prefer that.Tests:
RestoreCommand_WithAssetTargetFallbackFromProject_WarningsRaisedWhenApplicableand updated it as above.RestoreCommand_WithAssetTargetFallbackFromProject_NoWarnOnOneFramework_WarningRaisedForTheOther.RestoreCommand_WithAssetTargetFallbackFromProject_WithRuntimeIdentifier_WarningRaisedOnce, which also passes ondevand guards against repeating the warning for RID graphs.TargetGraphsassertions inRestoreCommand_AliasesandDotnetRestoreTests.Without the change, the first two and the
RestoreCommand_Aliasestest fail.On net10.0,
NuGet.Commands.FuncTest: 289 passed, 2 skipped. I didn't runDotnet.Integration.Testlocally, so the restored assertion inDotnetRestoreTestsrelies on CI.PR Checklist