From a31f840675d0cf1bd71105669d452c36027cd740 Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 11 Mar 2016 10:42:47 -0800 Subject: [PATCH] Rename environment variables to ASPNETCORE_. Remove the legacy ENV abbreviation. --- .../WebHostDefaults.cs | 2 +- .../Internal/WebHostConfiguration.cs | 2 +- src/Microsoft.AspNetCore.Hosting/Internal/WebHostOptions.cs | 4 +--- .../Common/DeploymentParameters.cs | 2 +- .../Deployers/ApplicationDeployer.cs | 2 +- .../WebHostConfigurationsTests.cs | 2 +- test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs | 4 +--- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore.Hosting.Abstractions/WebHostDefaults.cs b/src/Microsoft.AspNetCore.Hosting.Abstractions/WebHostDefaults.cs index 9a4cfca8..30a9a4b4 100644 --- a/src/Microsoft.AspNetCore.Hosting.Abstractions/WebHostDefaults.cs +++ b/src/Microsoft.AspNetCore.Hosting.Abstractions/WebHostDefaults.cs @@ -15,6 +15,6 @@ public static class WebHostDefaults public static readonly string ApplicationBaseKey = "applicationBase"; public static readonly string HostingJsonFile = "hosting.json"; - public static readonly string EnvironmentVariablesPrefix = "ASPNET_"; + public static readonly string EnvironmentVariablesPrefix = "ASPNETCORE_"; } } diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/WebHostConfiguration.cs b/src/Microsoft.AspNetCore.Hosting/Internal/WebHostConfiguration.cs index 65639d31..fff5d669 100644 --- a/src/Microsoft.AspNetCore.Hosting/Internal/WebHostConfiguration.cs +++ b/src/Microsoft.AspNetCore.Hosting/Internal/WebHostConfiguration.cs @@ -21,7 +21,7 @@ public static IConfiguration GetDefault(string[] args) }; // 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() .AddInMemoryCollection(defaultSettings) .AddJsonFile(WebHostDefaults.HostingJsonFile, optional: true) diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/WebHostOptions.cs b/src/Microsoft.AspNetCore.Hosting/Internal/WebHostOptions.cs index 53a8f5eb..f98a850c 100644 --- a/src/Microsoft.AspNetCore.Hosting/Internal/WebHostOptions.cs +++ b/src/Microsoft.AspNetCore.Hosting/Internal/WebHostOptions.cs @@ -8,8 +8,6 @@ namespace Microsoft.AspNetCore.Hosting.Internal { public class WebHostOptions { - private const string OldEnvironmentKey = "ENV"; - public WebHostOptions() { } @@ -24,7 +22,7 @@ public WebHostOptions(IConfiguration configuration) Application = configuration[WebHostDefaults.ApplicationKey]; DetailedErrors = ParseBool(configuration, WebHostDefaults.DetailedErrorsKey); CaptureStartupErrors = ParseBool(configuration, WebHostDefaults.CaptureStartupErrorsKey); - Environment = configuration[WebHostDefaults.EnvironmentKey] ?? configuration[OldEnvironmentKey]; + Environment = configuration[WebHostDefaults.EnvironmentKey]; ServerFactoryLocation = configuration[WebHostDefaults.ServerKey]; WebRoot = configuration[WebHostDefaults.WebRootKey]; ApplicationBasePath = configuration[WebHostDefaults.ApplicationBaseKey]; diff --git a/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs b/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs index 76ea430a..55df9abe 100644 --- a/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs +++ b/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs @@ -43,7 +43,7 @@ public DeploymentParameters( ApplicationPath = applicationPath; ServerType = serverType; RuntimeFlavor = runtimeFlavor; - EnvironmentVariables.Add(new KeyValuePair("ASPNET_DETAILEDERRORS", "true")); + EnvironmentVariables.Add(new KeyValuePair("ASPNETCORE_DETAILEDERRORS", "true")); } public ServerType ServerType { get; } diff --git a/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs b/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs index 67bc1966..472f1ac7 100644 --- a/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs @@ -161,7 +161,7 @@ protected void AddEnvironmentVariablesToProcess(ProcessStartInfo startInfo) startInfo.Environment; #endif - SetEnvironmentVariable(environment, "ASPNET_ENV", DeploymentParameters.EnvironmentName); + SetEnvironmentVariable(environment, "ASPNETCORE_ENVIRONMENT", DeploymentParameters.EnvironmentName); foreach (var environmentVariable in DeploymentParameters.EnvironmentVariables) { diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostConfigurationsTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostConfigurationsTests.cs index 2ef3c2a3..c975395e 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostConfigurationsTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostConfigurationsTests.cs @@ -44,7 +44,7 @@ public void ReadsParametersCorrectly() [Fact] public void ReadsOldEnvKey() { - var parameters = new Dictionary() { { "ENV", "Development" } }; + var parameters = new Dictionary() { { "ENVIRONMENT", "Development" } }; var config = new WebHostOptions(new ConfigurationBuilder().AddInMemoryCollection(parameters).Build()); Assert.Equal("Development", config.Environment); diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs index 2415591e..f5153e40 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs @@ -282,9 +282,7 @@ public void EnvDefaultsToConfigValueIfSpecifiedWithOldKey() { var vals = new Dictionary { - // Old key is actualy ASPNET_ENV but WebHostConfiguration expects environment - // variable names stripped from ASPNET_ prefix so using just ENV here - { "ENV", "Staging" } + { "environment", "Staging" } }; var builder = new ConfigurationBuilder()