Nearest Wins Resolution and Backward Compatibility

When you link to this ASP.NET github wiki page , it explains how packages of the same name (but with a different version) can be dropped using the "Closest Win" scenario:

Immediate gains mean that the dependency resolver prefers versions that are "closer" to the application, but only if they are ancestors of the dependency rejection.

The example provided explains how the image below Package B 1.0

will cast because Package B 2.0

"closer":

Nearest-Wins Dependency Resolution

Does this mean what Package A

will be used now Package B 2.0

? Surely it doesn't make sense if Package B 2.0

not compatible with Package B 1.0

?

According to the semantic version, the above packages are not necessarily backward compatible.

+3


source to share


1 answer


This means that MyApp will use PackageB 2.0, this also means that packageA in the context of MyApp will use PackageB 2.0. Note that there is always only one version of any single package in the package graph, this was true in the package.config world and there is no change here. In the packages.config world, this decision was made during user install of the package, where here the decision was made during restore.

Since the user or author of MyApp always creates a dependency graph in either project.json or nuspec (if MyApp was also a package), he can choose which version to use.

You are correct that there is a potential violation in this case according to the rules of semantic versioning. In this example, the author decided that it would not affect the application or, according to you, that it is compatible enough to use it.



Another important aspect to keep in mind is that the rule applies because the author of MyApp has the right to make changes, not because the B2.0 package is arbitrarily close to the root on the graph. Look at the cousin addiction rule to understand this edge case.

At the end of the document, the links to the question are not an official guide - it can be found here - https://docs.microsoft.com/en-us/nuget/consume-packages/dependency-resolution

+2


source







All Articles