Monday, April 14, 2014

Dependency Management

So, I like to use strong named assemblies1 and I am also coming to like NuGet.  Unfortunately, they hate each other.  Specifically, the NuGet community generally refuses to strong name their assemblies, for good reason, meaning that my strong named assemblies cannot reference them.  Seemingly at an impasse, I suddenly remembered this article from the 8th Light blog.  I realized that I shouldn't be referencing a NuGet package directly from my core assemblies anyway.  From that realization, the path becomes clear.  I created an abstract API wrapper for the functionality I needed as well as the infrastructure to load in an implementation at runtime.  Then I implemented my API in an assembly which is not strong named and can reference NuGet packages with impunity.  Another win for sound architecture and a proper level of abstraction.


1 I build my components in layers: one assembly for front-end, one for middle layer, etc, and one common assembly shared between them. It's useful to be able to use the InternalsVisibleToAttribute to limit the public API of the common assembly, but this requires the assemblies to be strongly typed.

No comments:

Post a Comment