Using Dependency Injection in Multiple .NET Core Projects

One of my last posts was about Dependency Injection (DI) in .NET Core Console Applications. Some days after that post was published, I got a question about how to use the IServiceCollection in multiple projects. In this post, I’m going to try to explain just that. 

To demonstrate that, I created solutions with two .NET Core Console apps and two .NET Standard libraries. One of the console apps uses two of the libraries, and the other one is just using one. Each library provides some services which need to be registered to the DI container. Also, the console apps provide some services to add.