Why does nuget force assembly binding redirects over downloading multiple versions?
I've been trying to find out why Nuget was designed the way it has been but I can't find an answer in among the thousands of questions around assembly binding errors. Npm just downloads specific versions if it needs to for sub dependencies so that you don't have to worry if two libraries are using different versions of the same sub dependency, so why does Nuget force you to merge everything into a single assembly for all dependencies?
The effect I see from an upgrade perspective is that you have this lag effect on new versions of libraries where breaking changes will leave you waiting until all other dependencies have upgraded to the latest version too. Code projects also have to actively maintain their app/web.config files so that at runtime the application can redirect any version to the one that Nuget has downloaded. So I can't really see any reason other than saving a bit on application size for Nuget to do it this way. Does anyone know more about why it does it this way?
Posted Mar 27, 2017, 11:41 AM UTC
.NET does simply not support loading multiple versions of the same assembly within a single AppDomain. So NuGet does the only sensible thing it can do. The alternative would be to simple refuse and break.
Does anyone know why that is? I assume it was a sensible design decision made early on, but it would be interesting to know the rationale for it.
Likely because of the type system. Otherwise class A from v1.0.0 would be incompatible with class A from v1.0.1 - since they're different types defined in different assemblies.