diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/HostingEnvironmentExtensions.cs b/src/Microsoft.AspNetCore.Hosting/Internal/HostingEnvironmentExtensions.cs index b38f997cac..50be22800b 100644 --- a/src/Microsoft.AspNetCore.Hosting/Internal/HostingEnvironmentExtensions.cs +++ b/src/Microsoft.AspNetCore.Hosting/Internal/HostingEnvironmentExtensions.cs @@ -63,7 +63,6 @@ namespace Microsoft.AspNetCore.Hosting.Internal hostingEnvironment.EnvironmentName = options.Environment ?? - Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? hostingEnvironment.EnvironmentName; } } diff --git a/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs b/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs index 88cd1c76fb..ef8589c572 100644 --- a/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs +++ b/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs @@ -45,6 +45,9 @@ namespace Microsoft.AspNetCore.Hosting _hostingEnvironment = new HostingEnvironment(); _configureServicesDelegates = new List>(); _configureLoggingDelegates = new List>(); + + // This may end up storing null, but that's indistinguishable from not adding it. + UseSetting(WebHostDefaults.EnvironmentKey, Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")); } ///