Open
Description
For internal reasons we create and validate the IConfiguration instance before building hosts. The .NET 6 WebApplicationBuilder lets us register this instance directly at the container:
var builder = WebApplicationBuilder.CreateBuilder();
OurConfigurationUtility.SetUp(builder.Configuration);
builder.Services.AddSingleton<IConfiguration>(builder.Configuration);
var startup = new Startup(builder.Configuration);
startup.ConfigureServices(builder.Services);
var app = builder.Build();
startup.Configure(app, app.Environment);
app.Run();
However, for our non-web background services we can't do the same with HostBuilder
. To our knowledge there is only the ConfigureAppConfiguration
method which already puts in some defaults and lets you work with a ConfigurationBuilder
but there is no way to put a finished IConfiguration
instance in, is there?
Best regards,
D.R.