When resolving P2P references for packaging, set target framework#42
Merged
When resolving P2P references for packaging, set target framework#42
Conversation
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.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
When MSBuild project references are resolved, in multi-targeting P2P references, the
SetTargetFrameworkmetadata is populated with the nearest target framework supported by the referenced project (from the referencing project's point of view). For example, if anetcore3.1project references anet5.0;netstandard2.1one, 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.