How do we isolate dependencies for a .Net app deploy in a way which is safe for a strongly-named assemblies

dependenciesdeploymentnet

To design in such that it is easy to deploy dependencies with your app, and so that development environments are easy to set up, it is advantageous to isolate an app's dependencies from it's environment. That means the app can get its dependencies from a package manager, and it will not be affected by it's deployment environment (such as the GAC). This principle comes from the Dependencies section of the very interesting "Twelve-Factor App" standards.

In .Net, I guess this would mean explicitly specifying to use dependencies from the bin folder of an app? I am concerned that this might cause problems for shared, strongly-named assemblies. In this Microsoft article, Ferrandez says locking conflicts can occur if apps do not share strongly-named assemblies via the GAC, since the assembly is loaded into a shared domain.

The 12-factor app describes the pieces needed to satisfy this principle as a dependency declaration manifest and a dependency isolation tool.

Does anyone have an established setup for isolating dependencies which is working for you, and is safe for strongly-named assemblies? Are we in the .Net world stuck with separating all our apps into VM's to achieve isolation?


Personal context: I maintain a SAAS app where each server instance runs a few services/apps which engage in some inter-process communication. They have some strongly-named dependencies in common. Having the dependencies in the GAC makes deployment complex, setting up dev environments a pain, and restricts freedom to choose deployment environments. Even without the strong naming or shared dependency issue, I am interested to know how people do dependency declaration and/or isolation. Thanks!

Best Answer

Using Nuget for library dependencies goes a long way toward dependency declaration and isolation.

The packages.config associated to each project can be read as a dependency declaration.

If those package references are marked 'private', they are bundled into the bin folder of your build outputs, and are presumably bundled for deployment. This avoids the requirement that all reference assemblies are GAC'd on the deployment box.

Related Topic