why we need to consolidate packages with different versions?

Viewed 81

Let's say I have a solution that have two projects. ProjectA uses a package whose version number is 2.0.0 and ProjectB uses the same package whose version number is 2.3.0 (ProjectB uses some more advanced features from the package). So when the solution is built, so I think VS adds two packages(one is 2.0.0, the other is 2.3.0). But VS also provides a consolidate tag when you manage nuget packages, so I can only think of one benefit to consolidate different versions- to reduce the size of assembly (in my case, uses 2.3.0), beside the size issue, is it any other benefits to consolidate packages with different versions?

1 Answers

Yes, less dependency problems. Imagine you have a ProjectC that references both ProjectA and ProjectB. The compiler will (usually!) resolve this automatically for you and use only the newer package, but since ProjectA was eventually built against 2.0.0, some compatibility problems might arise. This is particularly a problem if the versions of the dependent package are not binary compatible to each other (say, there's a method only available in 2.0 but removed for 2.3).

While the compiler tries hard to work around any possible version conflicts, I consider it a good idea to only use one version of a dependency within the same solution. It just reduces the headaches you get.

Related