Full restore support for aliasing - make the assets file aliasing aware - #6972
#6972Merged
nkolev92 merged 19 commits intoJan 30, 2026
devNuGet/NuGet.Client:devfrom
dev-nkolev92-supportV4FormatNuGet/NuGet.Client:dev-nkolev92-supportV4FormatCopy head branch name to clipboard
Merged
Full restore support for aliasing - make the assets file aliasing aware#6972nkolev92 merged 19 commits intodevNuGet/NuGet.Client:devfrom dev-nkolev92-supportV4FormatNuGet/NuGet.Client:dev-nkolev92-supportV4FormatCopy head branch name to clipboard
nkolev92 merged 19 commits into
devNuGet/NuGet.Client:devfrom
dev-nkolev92-supportV4FormatNuGet/NuGet.Client:dev-nkolev92-supportV4FormatCopy head branch name to clipboard
Conversation
nkolev92
force-pushed
the
dev-nkolev92-supportV4Format
branch
3 times, most recently
from
December 9, 2025 08:41
4827827 to
e7cded1
Compare
nkolev92
force-pushed
the
dev-nkolev92-supportV4Format
branch
3 times, most recently
from
December 10, 2025 17:28
7cbe95e to
863e076
Compare
This was referenced Dec 12, 2025
JanProvaznik
pushed a commit
to dotnet/msbuild
that referenced
this pull request
Dec 19, 2025
Fixes # ### Context Design: NuGet/Home#12124 To allow duplicate frameworks in aliasing, the project reference protocol nearest framework selection needs to be updated to support matching by alias as well. Relevant part: https://github.com/NuGet/Home/blob/dev-nkolev92-tfmaliases/accepted/2025/Multiple-Equivalent-Framework-Support-TFM-As-Aliases.md#project-to-project-references NuGet/NuGet.Client#7011 NuGet.Client side adding the parameter. NuGet/NuGet.Client#6972 will add the full implementation at a later point. ### Changes Made - Pass CurrentProjectTargetFrameworkProperty if GetReferenceNearestTargetFrameworkTaskSupportsTargetFrameworKPropertyParameter is set. - If GetReferenceNearestTargetFrameworkTaskSupportsTargetFrameworKPropertyParameter is not set, but GetReferenceNearestTargetFrameworkTaskSupportsTargetPlatformParameter is set, call the old variation. - Otherwise calls the last variation. ### Testing - Manual testing. - I'd be happy to add tests if someone can point me in the right direction. ### Notes The idea here is to get ahead of things. Currently aliasing work can't be end to end tested because it requires an msbuild change. It makes it really hard to validate the NuGet changes are enough and good, but this is the only change needed on the msbuild side. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
nkolev92
force-pushed
the
dev-nkolev92-supportV4Format
branch
4 times, most recently
from
January 16, 2026 22:18
2c2a38f to
2d62c8b
Compare
3 tasks
nkolev92
force-pushed
the
dev-nkolev92-supportV4Format
branch
3 times, most recently
from
January 24, 2026 00:57
91829c0 to
1d505fc
Compare
nkolev92
force-pushed
the
dev-nkolev92-supportV4Format
branch
from
January 26, 2026 19:30
1d505fc to
0db929a
Compare
nkolev92
marked this pull request as ready for review
January 26, 2026 19:30
zivkan
reviewed
Jan 29, 2026
zivkan
left a comment
Member
There was a problem hiding this comment.
Just finished going through the product code, but haven't started looking at the tests yet. Thought I'd share my comments so far.
zivkan
previously approved these changes
Jan 30, 2026
zivkan
left a comment
Member
There was a problem hiding this comment.
I always find tests hard to review. They all look so similar, making it hard to see the differences between them. I don't have any ideas how to make it better though.
jeffkl
reviewed
Jan 30, 2026
jeffkl
left a comment
Contributor
There was a problem hiding this comment.
Thanks for undoing the breaking changes
jeffkl
self-requested a review
January 30, 2026 18:46
Member
Author
nkolev92
enabled auto-merge (squash)
January 30, 2026 19:46
zivkan
previously approved these changes
Jan 30, 2026
jeffkl
previously approved these changes
Jan 30, 2026
zivkan
approved these changes
Jan 30, 2026
jeffkl
approved these changes
Jan 30, 2026
This was referenced Feb 2, 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#14534
Fixes: NuGet/Home#14536
Description
This PR implements the restore part of NuGet/Home#12124.
The short summary is:
Some more helpers for the review:
Assets file and dg spec (packagespec) read/write changes pointers:
The PackageSpecWriter, which writes the package spec, has a legacy and "new" writer. This writer is used in 3 different places. The assets file file, the dg spec writer (dgspec.json in the obj folder) and the no-op hash. In order to avoid having to version the package spec, we only use the legacy writer in the assets file, when the version is 3. This ensures all of our tests are actually covering the new codepath and we don't accidentally break the legacy projects. The way the package spec writer is implemented probably allows the legacy projects to have v4 of the assets file, but I'd rather do that at a later point to minimize the risk of this current change.
Every time we write the package spec now, we write a "framework", which is basically the effective framework. For simplicity, we write this every time.
LockFileTarget.Name is what's being written as the key, so in LockFileBuilder, we set the Name based on the version. Similarly, the LockFileTarget reader, v3 and v4, will set the name based on the version. If V3, we fill out the TargetAlias, if V4, we fill out the Framework (which is not longer written).
In LockFileFormat, the default version is 4. Whenever we use V4 of the LockFileFormat (or assets file), we use the default package spec writer, with version 3, we use the legacy writer.
I cleaned up any global suppressions whenever I saw it fit. The fewer of these we have, the better.
PR Checklist