-
Notifications
You must be signed in to change notification settings - Fork 391
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
Transitive dependency items not attached for all target frameworks when multi-targeting #6832
Comments
When a project is multi-targeting, the code in NuGet.Client that attaches transitive dependency information to dependency nodes must determine which target each item belongs to. This doesn't work correctly for certain target framework kinds today. Given: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net481;netcoreapp3.1;netstandard2.1;net5.0;net6.0;net7.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MetadataExtractor" Version="2.8.0" />
</ItemGroup>
</Project> We see: Only The reason for this is inconsistent treatment of the target identifier in the These are two different kinds of values, which makes this mapping difficult. Perhaps we need to store both the alias and the TFM on the target node, so the NuGet code can try and find either. Or NuGet could settle on a single identifier in this file. Or something else. The JSON file does have, under So perhaps it could map these back, however they appear in a different order, and I can't see any other way in the data model to do that mapping such that we have only a single kind of identifier. |
TODO investigate any relationship to |
Another scenario to test: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net35;net35-client</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net35-client'">
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MetadataExtractor" Version="2.8.0" Condition="'$(TargetFramework)' == 'net35-client'" />
</ItemGroup>
</Project> |
Another case of this is specifying |
@drewnoakes assuming the assets file was parsed with NuGet.ProjectModel (and therfore Note that API might change when NuGet/Home#5154 is implemented If you're not parsing with |
…projects Fixes dotnet/project-system#6832 The "target name" used in the project model can take different forms. For example, both `net8.0` and `.NETFramework,Version=v4.8.1` are valid values. The dependencies tree uses the "target alias" for its target nodes, in multi-target projects. This is because two different aliases can resolve to the same TFM, for example, yet attached items may differ. This change digs the alias out of the lock file and uses that value throughout. It also renames a property and fixes the documentation on it so as to avoid confusion.
Thanks @zivkan. That was really helpful. I filed NuGet/NuGet.Client#5507 which fixes this issue.
That's fine, as the code is in the NuGet.Client solution so will be included in any refactoring there. |
Following the merge of PR #6712 (which fixed several bugs) we see some package and project reference nodes not having their children populated for multi-targeting projects. That PR changed the representation of the target we store on these items, which is now no longer understood by the code that attaches these children.
We are no longer parsing the
TargetFramework
dimension to produce a sanitised version for external consumption. Internally this works well enough as an opaque identifier, however it breaks when we communicate that information externally, in this case to the code in NuGet.Client that populates descendents of package and project references.The fix is likely to capture whatever property values we need information from the
ConfiguredProject
and pass that throughout the system in ourTargetFramework
class. There are some rough edges here that will make this challenging and require careful thought.The text was updated successfully, but these errors were encountered: