Repository navigation
Use target graph name with framework - #7156
Merged
Merged
Conversation
Member
Author
|
Cherry-pick of #7154. |
donnie-msft
approved these changes
Feb 20, 2026
Nigusu-Allehu
approved these changes
Feb 20, 2026
jebriede
reviewed
Feb 20, 2026
| var assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json"); | ||
| var assetsFile = new LockFileFormat().Read(assetsFilePath); | ||
| LockFileTarget appleTarget = assetsFile.GetTarget(apple, null); | ||
| appleTarget.Libraries.Should().NotContain(e => e.Name.Equals("x")); |
Contributor
There was a problem hiding this comment.
The assertion checks that libraries should NOT contain "x", but the test setup doesn't seem to create a package named "x". Should this be checking for "packageA" instead?
Member
Author
There was a problem hiding this comment.
Yeah, it should be packageA.
In reality, it should probably just not even assert this.
The true test is the next line 3469
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#14756
Description
This is the patch friendly version of #7153.
In #6805 and more notably in #6923 a sizable part of the restore core logic was reworked to consider aliases as pivot instead of NuGetFramework.
Turns out that was handled pretty well in most cases, except in scenarios where the TargetFramework element does not actually match the GetShortFolderName of a framework.
In these cases, package specific suppressions do not work.
An example is net10.0-windows frameworks. Maui projects would probably suffer from the same issue as well as the linked issues suggest.
Originally in #6805 and #6923 a large majority of the internal restore infrastructure was changed to use string alias, instead of the NuGetFramework.
Note that this work was done in a way that didn't make intentional functional changes, but simply made changes that are purely internal.
Turns out that it ended up breaking package specific warning suppressions for aliased frameworks such as net10.0-windows. Projects like maui have this issue as well.
The root cause for that is that now all RestoreLogMessage have a target graph that has the alias. Note that this TargetGraphName is shared in many places, so it'll be really hard to understand the impact it'd have if we chnaged it for log messages only.
Workaround: Set the full name of the TargetFramework, so for net10.0-windows set net10.0-windows7.0.
The simplest solution here is to change the TargetGraphName to the previous behavior, which is framework/rid instead of alias/rid.
This is insufficient with aliasing, but plenty good for a patch.
The only place beyond NuGet where these strings are being read is the SDK and the SDK already knows how to handle both dotnet/sdk#50694, so this shouldn't be an issue.
PR Checklist
Added testsLink to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.