Am running .net core 2.2 and hosting asp.net core within a windows service.
eg. see this https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-2.2&tabs=visual-studio
I set the environment variable ASPNETCORE_ENVIRONMENT to "Dev"
Just to confirm, within my launchsettings.json
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT ": "Dev"
}
When starting up the value of HostingEnvironment.EnvironmentName is not updated and still has "Production" which is default. Why is it not "Dev"?
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddEventLog();
})
.ConfigureAppConfiguration((context, config) =>
{
// Configure the app here.
var env = context.HostingEnvironment;
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
})
.UseStartup<Startup>();
}
