I have been trying to get some dependency injection
into my .net
core console app as well as use an appsettings.json file
.
However I can't find an example with both together.
Below is a method I have to set this up from inside my Main()
private static IContainer SetupDependencyInjection()
{
var builder2 = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
var builder = new ContainerBuilder();
builder.RegisterAssemblyTypes(
typeof(Program).GetTypeInfo().Assembly // Console
)
.AsSelf()
.AsImplementedInterfaces();
var container = builder.Build();
return container;
}
You can see I have the builder2 variable to set up the config file but then I need the builder variable for the Dependency Injection.
Any ideas on this?