dotnet / project-system

The .NET Project System for Visual Studio
MIT License
959 stars 386 forks source link

Using multiple Directory.Packages.props does not work as documented #9379

Closed aaronenberg closed 5 months ago

aaronenberg commented 5 months ago

Visual Studio Version

17.8.4

Summary

When importing a parent Directory.Packages.props into the closest Directory.Packages.props and both specify a different PackageVersion of a given package, the PackageVersion in the parent is always chosen instead of the closest PackageVersion.

The CPM documentation gives an example use-case of this scenario, where supposedly it is showing how to use Import to inherit packages from the parent while overriding the PackageVersion of Newtonsoft.Json for a project. But it doesn't actually work that way.

Steps to Reproduce

Just follow the example in CPM documentation, the project will use the Newtonsoft.Json version specified in imported parent Directory.Packages.props instead of the closest.

Expected Behavior

For a given package, the PackageVersion of the closest Directory.Packages.props should be used when importing a parent Directory.Packages.props that specifies a different PackageVersion.

Actual Behavior

For a given package, the PackageVersion of the parent Directory.Packages.props is used when importing it into a closer Directory.Packages.props that specifies a different PackageVersion.

User Impact

Importing Directory.Packages.props is useless with this behavior for non-trivial, multiple-project solutions.

aaronenberg commented 5 months ago

Nevermind, I didn't realize that the Include needs to be changed to Update