Skip to content

When resolving P2P references for packaging, set target framework#42

Merged
kzu merged 1 commit intomainfrom
nearest-framework
Dec 4, 2020
Merged

When resolving P2P references for packaging, set target framework#42
kzu merged 1 commit intomainfrom
nearest-framework

Conversation

@kzu
Copy link
Copy Markdown
Member

@kzu kzu commented Dec 4, 2020

When MSBuild project references are resolved, in multi-targeting P2P references, the SetTargetFramework metadata is populated with the nearest target framework supported by the referenced project (from the referencing project's point of view). For example, if a netcore3.1 project references a net5.0;netstandard2.1 one, when resolving the contents for the referenced project, the built-in targets will properly calculate (using the NuGet-provided GetReferenceNearestTargetFrameworkTask task) the target framework compatible with the referencing project.

If we don't set the target framework, we end up inadvertently invoking targets on the project reference using the calling project target framework (in this case netcoreapp3.1), which is not supported by the referenced project and we end up with a missing MSBuild target import (since NuGet conditions the .props/.targets imports to the target framework), and it ends up manifesting itself as an error that the reference hasn't been nugetized, when in fact it's because we're invoking with the wrong TF.

Fixes #27.

When MSBuild project references are resolved, in multi-targeting P2P references, the `SetTargetFramework` metadata is populated with the nearest target framework supported by the referenced project (from the referencing project's point of view). For example, if a `netcore3.1` project references a `net5.0;netstandard2.1` one, when resolving the contents for the referenced project, the built-in targets will properly calculate (using the NuGet-provided GetReferenceNearestTargetFrameworkTask task) the target framework compatible with the referencing project.

If we don't set the target framework, we end up inadvertently invoking targets on the project reference using the *calling* project target framework (in this case `netcoreapp3.1`), which is not supported by the referenced project and we end up with a missing MSBuild target import (since NuGet conditions the .props/.targets imports to the target framework), and it ends up manifesting itself as an error that the reference hasn't been nugetized, when in fact it's because we're invoking with the wrong TF.

Fixes #27.
@kzu kzu merged commit dae123f into main Dec 4, 2020
@kzu kzu deleted the nearest-framework branch December 4, 2020 04:56
@devlooped devlooped locked and limited conversation to collaborators Nov 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multitarget Issues

1 participant