I am heavily using dependency injection in my application. As such, my components reference interfaces, and the concrete implementations are known only to my IoC container, configured through XML files.
A consequence of this design is that I end up needing assemblies in my bin folder (e.g. Newtonsoft.Json, SqlLite) that I have no need to reference in my project. In fact, I explictly do not want references, as I or my team may accidentally refer to a concrete implementation rather than an interface, thereby destroying the advantages of the DI we're using.
The _bin_DeployableAssemblies folder introduced in VS 2010 SP1 was useful for this scenario, but applied only to web projects (I'm personally using MVC3 and ok with that, but it doesn't solve the general problem. However, it appears to be more or less deprecated in VS11 Beta. Copying the files into the bin directory prior to build feels icky - the bin folder is no longer a container for build artifacts. I suppose a custom post-build event could be used, but it seems there should be something more "out of the box" to solve this problem. Am I stuck with post-build? What other ways are there to tackle this issue?
There are a couple of ways to handle this:
I sometimes use the second option. This does have the advantage of keeping the "dependency" obvious to developers, while still preventing them from actually using the types defined within the assemblies, as they are not references and the compiler will not see them as available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With