Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@nkolev92
Copy link
Contributor

@nkolev92 nkolev92 commented Dec 12, 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.

@nkolev92 nkolev92 marked this pull request as ready for review December 16, 2025 02:18
@nkolev92 nkolev92 force-pushed the dev-nkolev92-addExtraParameterToGetNearest branch from 247f151 to 559afab Compare December 16, 2025 02:18
Copilot AI review requested due to automatic review settings December 16, 2025 02:18
@nkolev92
Copy link
Contributor Author

cc @rainersigwald

Copy link
Contributor

Copilot AI left a 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 CurrentProjectTargetFrameworkProperty parameter to the GetReferenceNearestTargetFrameworkTask call
  • 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

@JanProvaznik JanProvaznik merged commit 3af5ec0 into main Dec 19, 2025
10 checks passed
@JanProvaznik JanProvaznik deleted the dev-nkolev92-addExtraParameterToGetNearest branch December 19, 2025 09:37
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