How to use Startup.cs with WebAppliationBuilder

User Secrets is very useful, but it's only loaded with WebApplicationBuilder, not with WebHostBuilder.

If you're using an existing Startup.cs with WebApplicationBuilder, you can manually create and use a Startup instance.

var builder = WebApplciationBuilder.CreateBuilder(args);

var startup = new Startup(builder.Configuration);

startup.ConfigureServices(builder.Services);

var app = builder.Build();

startup.Configure(app, app.Services.GetRequiredService<MyDependenent>());

app.Run();