Skip to content

[API Proposal]: Like WebApplicationBuilder allow us to put a finished IConfiugration instance into a HostBuilder #110051

Open
@drauch

Description

@drauch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Extensions-ConfigurationquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions