aspnet / MetaPackages

[Archived] NuGet meta packages. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
211 stars 109 forks source link

Added a method to configure the web host defaults #298

Closed davidfowl closed 5 years ago

davidfowl commented 5 years ago

An alternative approach is to add a UseWebHostDefaults that just configures these things so we don't have 2 methods:

Option 1

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(builder =>
        {
            builder.UseStartup<Startup>();
        });

Option 2

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .UseWebHostDefaults()
        .ConfigureWebHost(builder =>
        {
            builder.UseStartup<Startup>();
        });

PS: This doesn't do the defaults that aren't specific to the web stuff. We still need to figure out where that goes.

Tratcher commented 5 years ago

Update https://github.com/aspnet/MetaPackages/blob/master/samples/SampleApp/Program.cs

Tratcher commented 5 years ago

As for Host.CreateDefaultBuilder(args), all its dependencies are in Extensions so how about adding a new package in Hosting called Microsoft.Extensions.Hosting.Defaults that pulls it together?

davidfowl commented 5 years ago

As for Host.CreateDefaultBuilder(args), all its dependencies are in Extensions so how about adding a new package in Hosting called Microsoft.Extensions.Hosting.Defaults that pulls it together?

Yep. I'm not sure I love the name but until I find a new one we'll go with that for now.