Skip to content

Use target graph name with framework - #7156

Merged
nkolev92 merged 2 commits into
release/7.4.xfrom
dev-nkolev92-targetGraphName
Feb 20, 2026
Merged

nkolev92 merged 2 commits into
release/7.4.xfrom
dev-nkolev92-targetGraphName

Conversation

@nkolev92

Copy link
Copy Markdown
Member

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

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@nkolev92
nkolev92 requested a review from a team as a code owner February 20, 2026 17:15
@nkolev92

Copy link
Copy Markdown
Member Author

Cherry-pick of #7154.

@nkolev92
nkolev92 merged commit 1ad32d1 into release/7.4.x Feb 20, 2026
11 of 16 checks passed
@nkolev92
nkolev92 deleted the dev-nkolev92-targetGraphName branch February 20, 2026 18:19
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"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it should be packageA.

In reality, it should probably just not even assert this.
The true test is the next line 3469

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants