Rename environment variables to ASPNETCORE_. Remove the legacy ENV abbreviation.
This commit is contained in:
parent
a77e7cf6da
commit
a31f840675
|
|
@ -15,6 +15,6 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
public static readonly string ApplicationBaseKey = "applicationBase";
|
public static readonly string ApplicationBaseKey = "applicationBase";
|
||||||
|
|
||||||
public static readonly string HostingJsonFile = "hosting.json";
|
public static readonly string HostingJsonFile = "hosting.json";
|
||||||
public static readonly string EnvironmentVariablesPrefix = "ASPNET_";
|
public static readonly string EnvironmentVariablesPrefix = "ASPNETCORE_";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
};
|
};
|
||||||
|
|
||||||
// Setup the default locations for finding hosting configuration options
|
// Setup the default locations for finding hosting configuration options
|
||||||
// hosting.json, ASPNET_ prefixed env variables and command line arguments
|
// hosting.json, ASPNETCORE_ prefixed env variables and command line arguments
|
||||||
var configBuilder = new ConfigurationBuilder()
|
var configBuilder = new ConfigurationBuilder()
|
||||||
.AddInMemoryCollection(defaultSettings)
|
.AddInMemoryCollection(defaultSettings)
|
||||||
.AddJsonFile(WebHostDefaults.HostingJsonFile, optional: true)
|
.AddJsonFile(WebHostDefaults.HostingJsonFile, optional: true)
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
{
|
{
|
||||||
public class WebHostOptions
|
public class WebHostOptions
|
||||||
{
|
{
|
||||||
private const string OldEnvironmentKey = "ENV";
|
|
||||||
|
|
||||||
public WebHostOptions()
|
public WebHostOptions()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -24,7 +22,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
Application = configuration[WebHostDefaults.ApplicationKey];
|
Application = configuration[WebHostDefaults.ApplicationKey];
|
||||||
DetailedErrors = ParseBool(configuration, WebHostDefaults.DetailedErrorsKey);
|
DetailedErrors = ParseBool(configuration, WebHostDefaults.DetailedErrorsKey);
|
||||||
CaptureStartupErrors = ParseBool(configuration, WebHostDefaults.CaptureStartupErrorsKey);
|
CaptureStartupErrors = ParseBool(configuration, WebHostDefaults.CaptureStartupErrorsKey);
|
||||||
Environment = configuration[WebHostDefaults.EnvironmentKey] ?? configuration[OldEnvironmentKey];
|
Environment = configuration[WebHostDefaults.EnvironmentKey];
|
||||||
ServerFactoryLocation = configuration[WebHostDefaults.ServerKey];
|
ServerFactoryLocation = configuration[WebHostDefaults.ServerKey];
|
||||||
WebRoot = configuration[WebHostDefaults.WebRootKey];
|
WebRoot = configuration[WebHostDefaults.WebRootKey];
|
||||||
ApplicationBasePath = configuration[WebHostDefaults.ApplicationBaseKey];
|
ApplicationBasePath = configuration[WebHostDefaults.ApplicationBaseKey];
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Server.Testing
|
||||||
ApplicationPath = applicationPath;
|
ApplicationPath = applicationPath;
|
||||||
ServerType = serverType;
|
ServerType = serverType;
|
||||||
RuntimeFlavor = runtimeFlavor;
|
RuntimeFlavor = runtimeFlavor;
|
||||||
EnvironmentVariables.Add(new KeyValuePair<string, string>("ASPNET_DETAILEDERRORS", "true"));
|
EnvironmentVariables.Add(new KeyValuePair<string, string>("ASPNETCORE_DETAILEDERRORS", "true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerType ServerType { get; }
|
public ServerType ServerType { get; }
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Server.Testing
|
||||||
startInfo.Environment;
|
startInfo.Environment;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetEnvironmentVariable(environment, "ASPNET_ENV", DeploymentParameters.EnvironmentName);
|
SetEnvironmentVariable(environment, "ASPNETCORE_ENVIRONMENT", DeploymentParameters.EnvironmentName);
|
||||||
|
|
||||||
foreach (var environmentVariable in DeploymentParameters.EnvironmentVariables)
|
foreach (var environmentVariable in DeploymentParameters.EnvironmentVariables)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ReadsOldEnvKey()
|
public void ReadsOldEnvKey()
|
||||||
{
|
{
|
||||||
var parameters = new Dictionary<string, string>() { { "ENV", "Development" } };
|
var parameters = new Dictionary<string, string>() { { "ENVIRONMENT", "Development" } };
|
||||||
var config = new WebHostOptions(new ConfigurationBuilder().AddInMemoryCollection(parameters).Build());
|
var config = new WebHostOptions(new ConfigurationBuilder().AddInMemoryCollection(parameters).Build());
|
||||||
|
|
||||||
Assert.Equal("Development", config.Environment);
|
Assert.Equal("Development", config.Environment);
|
||||||
|
|
|
||||||
|
|
@ -282,9 +282,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
var vals = new Dictionary<string, string>
|
var vals = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
// Old key is actualy ASPNET_ENV but WebHostConfiguration expects environment
|
{ "environment", "Staging" }
|
||||||
// variable names stripped from ASPNET_ prefix so using just ENV here
|
|
||||||
{ "ENV", "Staging" }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue