So in the project I am currently working on, we have 1 MVC project and 5 MVC/Web API projects as part of one VS 2013 solution. The MVC only project is chosen as the start up website, because it will be consumer facing. The remaining 5 projects are referenced by this MVC project, which calls the API controllers for fetching and pushing data.
Currently, we have Unity Bootstrapper, Unity.MVC and Unity.WebAPI Nuget packages installed in the customer facing MVC website, and the DI works just fine, when we call individual Web API projects.
Now, there is also a requirement, that we should be able to individually test 5 of the MVC/Web API projects, where we create test .cshtml razor views, test MVC Controllers, which call the API controllers. Now since the MVC/Web API project is being run individually, and not being called via the MVC Website, there is no IOC to wire up dependencies. So I installed the above mentioned Nuget packages to each of the 5 projects, and wired up dependencies required by them. Now each of the individual projects worked fine.
However, when I now ran the main MVC project/website, it would fire off the Unity Bootstrappers in all the referenced MVC/Web API projects, thus overwriting the previously instantiated Unity Container. So essentially, the very last MVC/Web API project serves it's Unity Container as the DI container for the website.
Is there any way to fix this? Should I go about creating UnityExtensions for each of the Web API projects, and wire them up individually in the MVC project?