Closed halter73 closed 6 years ago
Does this include populating urls from the appconfig.json?
As mentioned here https://github.com/aspnet/Hosting/issues/1230
@leak This issue is proposing a smaller change. In our templates, appsettings.json isn't read until after the WebHost is built, so it would take a pretty significant change to our templates to make your suggestion work.
Populating endpoints from config is a known pain point, and we're tracking progress on that front in aspnet/KestrelHttpServer#1290.
@leak In the meantime, I recommend using the workaround suggested in https://stackoverflow.com/a/44118610/719967.
I'm assuming this is the reason why --environment Development
and similar also doesn't do much? this would be great to have when deploying windows services for different environments where setting env vars is hard.
@dasMulli yes. Here's the workaround from the linked issue:
public static IWebHost BuildWebHost(string[] args)
{
var configuration = new ConfigurationBuilder().AddCommandLine(args).Build();
return WebHost.CreateDefaultBuilder(args)
.UseConfiguration(configuration)
.UseStartup<Startup>()
.Build();
}
aspnet/KestrelHttpServer#1998 brought this issue to my attention. I posted a fairly simple workaround there.
It would be more intuitive to populate the WebHostBuilder config/settings in addition to the app config with the args passed into
WebHost.CreateDefaultBuilder(args)
.This would make
dotnet run --urls "http://localhost:5001"
work out of the box.