-
Notifications
You must be signed in to change notification settings - Fork 252
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
PrivateAssets flow incorrectly to transitively pinned centrally managed dependencies #12270
Comments
@marcin-krystianc I don't think I understand what you're saying in the description. PrivateAssets should end up in a Test.csproj <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json.Bson" PrivateAssets="Compile;Runtime" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" PrivateAssets="Compile" />
</ItemGroup>
</Project> Directory.Packages.props <Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
<PackageVersion Include="Newtonsoft.Json.Bson" Version="1.0.2" />
<PackageVersion Include="Microsoft.Rest.ClientRuntime" Version="2.3.24" />
</ItemGroup>
</Project> And the assets file has this: "centralTransitiveDependencyGroups": {
".NETStandard,Version=v2.0": {
"Newtonsoft.Json": {
"include": "Runtime, Compile, Native, BuildTransitive",
"suppressParent": "Runtime, Compile",
"version": "[13.0.1, )"
}
}
} NuGet takes the union of But your example looks totally different and says that you get an empty |
Ah, I think I've been playing with different examples which led to messing up my description. You are right, that my original example doesn't make sense 😞 <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json.Bson" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" PrivateAssets="All" />
</ItemGroup>
</Project> and <Project>
<ItemGroup>
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
<PackageVersion Include="Newtonsoft.Json.Bson" Version="1.0.2" />
<PackageVersion Include="Microsoft.Rest.ClientRuntime" Version="2.3.24" />
</ItemGroup>
</Project> The expected content of "centralTransitiveDependencyGroups": {
".NETStandard,Version=v2.0": {
"Newtonsoft.Json": {
"include": "Runtime, Compile, Native, BuildTransitive",
"version": "[13.0.1, )"
}
}
} , but the SDK 7.0.100 produces empty The rationale is that adding |
@marcin-krystianc I think I'm convinced we need this fixed but I want to get consensus on the output. Assuming PackageA and PackageB reference the same PackageC. The default PrivateAssets if you don't specify anything is
So I'm going to push a commit to your branch to get it updated and have the test try a few different permutations. |
Sure, adding more tests is always a good idea :-) I can also do it if you want. |
I'm still experimenting so it'll probably just be easier to push the branch then explain what I'm after. I'll do it soon... |
I finally think I got it figured out. You're absolutely right that the assets should be the intersection. However, the missing piece was that transitive dependencies have different defaults than direct dependencies. This was causing some confusion for me when I was updating the unit test and getting unexpected results. But I think I have it figured out so I force pushed to your branch. I'll get this reviewed and merged next week. Thanks again for the contribution, I hope taking over the branch doesn't make you think we are any less grateful. I think in this case the scenario was just too complicated to understand without me getting myself involved. Your contribution is greatly appreciated! |
NuGet Product Used
dotnet.exe
Product Version
7.0.100
Worked before?
no
Impact
It bothers me. A fix would be nice
Repro Steps & Context
For project:
and
Directory.Packages.props
:The expected content of
centralTransitiveDependencyGroups
is:, but the SDK 7.0.100 produces empty
centralTransitiveDependencyGroups
.PS:
I'm going to submit a PR with a fix.
Verbose Logs
No response
The text was updated successfully, but these errors were encountered: