-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add extra parameter to get nearest #12932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extra parameter to get nearest #12932
Conversation
247f151 to
559afab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for passing the target framework property (TargetFramework) to the GetReferenceNearestTargetFrameworkTask to enable framework aliasing support. This change allows NuGet's project reference protocol to match frameworks by both their moniker and their alias, which is necessary for supporting duplicate frameworks with different aliases.
Key Changes:
- Add new
CurrentProjectTargetFrameworkPropertyparameter to theGetReferenceNearestTargetFrameworkTaskcall - Implement backward compatibility by maintaining three separate invocation paths based on feature flags
- Update documentation to reflect the new parameter availability in MSBuild 18.3
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Tasks/Microsoft.Common.CurrentVersion.targets | Adds three-tier invocation logic for GetReferenceNearestTargetFrameworkTask with backward compatibility, passing CurrentProjectTargetFrameworkProperty when supported |
| documentation/ProjectReference-Protocol.md | Documents the new TargetFramework metadata availability in MSBuild 18.3 |
Co-authored-by: Copilot <[email protected]>
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
Testing
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.