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.
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.