I have a question about Nuget and its management.
Let's assume two scenarios here:
I have two Nuget packages A and B in my application. They depend on C which is also a Nuget package, but I don't need to declare the C package in my application.
Scenario 1. A depends on C in version 1.0. B depends on C in version 2.0. How will Nuget handle this situation?
Scenario 2. A depends on C in version 1.0. B depends on C in version 1.0. Can I upgrade package C which is used in package B and for A and rest of the project still version 1.0?
Thanks a lot for all the answers!
CodePudding user response:
Take a look at the NuGet documentation especially NuGet Package Dependency Resolution. Also look at NuGet PackageReference in project files.
Note that in a PackageReference the Version that is specified is the lowest version that can be used. The following reference means that package C >= 1.0.0 can be used.
<PackageReference Include="C" Version="1.0.0" />
You can't have two versions of package C in one application. In scenario 1 assuming A was built with a dependency on C >= 1.0.0 and B was built with a dependency on C >= 2.0.0, then in an application that uses A and B NuGet will use C v2.0.0 because that is the lowest version that satisfies both packages A and B.