Skip to content

Add alias to LockFileTarget and IRestoreTargetGraph, pivot based on alias in restore - #6805

Merged
nkolev92 merged 4 commits into
devfrom
dev-nkolev92-addAliasToLockFileFormatAndTargetGraph
Oct 2, 2025
Merged

nkolev92 merged 4 commits into
devfrom
dev-nkolev92-addAliasToLockFileFormatAndTargetGraph

Conversation

@nkolev92

@nkolev92 nkolev92 commented Sep 25, 2025 •

Copy link
Copy Markdown
Member

Bug

Fixes: NuGet/Home#14577

Description

The full implementation of aliasing allows multiple TargetFramework with the same effective tfm.
In order to achieve that, we will need to change up a bunch of the NuGet internal types to be identifiable by TargetAlias as well.
In this PR, I migrate our multiplexing to aliasing and attaching alias to 2 types that will inevitably need it, which is:

  • LockFileTarget, the type that expresses the targets element in the assets file, which is currently pivoted off the effective TFM full name.
  • IRestoreTargetGraph - the result type for a restore graph. Each tfm/rid combo currently gets its own IRestoreTargetGraph.
  • Added FrameworkRuntimeDefinition (instead of reusing framework runtime pair, which itself contains the alias as well. Looking for feedback on the name here. I made the type internal, because we don't really need to expose, so we can easily iterate on the name.
  • While both new and old resolver will label their RestoreTargetGraph results with TargetAlias, only the new one will eventually support full aliasing.
  • "Supports" or compatibility profiles restore in the legacy resolver cannot really be supported correctly because some of the TFMs specified there are new and different from one originally specified, so we do a best effort and while it leads to an alias that doesn't exist, there is really no component that would actually use it. "Supports" is really just a restore thing.
  • LockFile - I removed the unused methods. This just simplifies the amount of code we need to maintain.
  • LockFileTarget - The restore code generates a LockFileTarget with an alias based on RestoreTargetGraph, but we we read it off disk, we need to patch it up, which is what Utf8JsonStreamLockFileConverter does.
    This is important because it allows everyone to depend on the TargetAlias regardless of what the lock file format itself is.
  • PackageSpecExtensions - added ways to look up a TFI and PRMFI based on an alias instead of just a framework.

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 force-pushed the dev-nkolev92-addAliasToLockFileFormatAndTargetGraph branch from 9596d57 to 005c96b Compare September 29, 2025 19:27
@nkolev92
nkolev92 marked this pull request as ready for review September 30, 2025 22:11
@nkolev92
nkolev92 requested a review from a team as a code owner September 30, 2025 22:11
@nkolev92
nkolev92 force-pushed the dev-nkolev92-addAliasToLockFileFormatAndTargetGraph branch from 9f6953a to 48067c4 Compare October 1, 2025 21:44
@nkolev92
nkolev92 force-pushed the dev-nkolev92-addAliasToLockFileFormatAndTargetGraph branch from 48067c4 to 32aa481 Compare October 2, 2025 00:42
zivkan
zivkan previously approved these changes Oct 2, 2025
Comment thread src/NuGet.Core/NuGet.Commands/RestoreCommand/FrameworkRuntimeDefinition.cs Outdated
Comment thread src/NuGet.Core/NuGet.Commands/RestoreCommand/RestoreCommand.cs Outdated
Comment thread src/NuGet.Core/NuGet.Commands/RestoreCommand/RestoreCommand.cs Outdated
Comment thread src/NuGet.Core/NuGet.ProjectModel/PackageSpecExtensions.cs Outdated
@nkolev92
nkolev92 requested a review from zivkan October 2, 2025 15:54
Comment thread src/NuGet.Core/NuGet.Commands/RestoreCommand/DependencyGraphResolver.cs Outdated
@nkolev92
nkolev92 requested a review from jeffkl October 2, 2025 17:47
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.

LockFileTarget and IRestoreTargetGraph are labeled with an alias

3 participants