Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Commit a31f840

Browse files
committed
Rename environment variables to ASPNETCORE_. Remove the legacy ENV abbreviation.
1 parent a77e7cf commit a31f840

File tree

7 files changed

+7
-11
lines changed

7 files changed

+7
-11
lines changed

src/Microsoft.AspNetCore.Hosting.Abstractions/WebHostDefaults.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public static class WebHostDefaults
1515
public static readonly string ApplicationBaseKey = "applicationBase";
1616

1717
public static readonly string HostingJsonFile = "hosting.json";
18-
public static readonly string EnvironmentVariablesPrefix = "ASPNET_";
18+
public static readonly string EnvironmentVariablesPrefix = "ASPNETCORE_";
1919
}
2020
}

src/Microsoft.AspNetCore.Hosting/Internal/WebHostConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static IConfiguration GetDefault(string[] args)
2121
};
2222

2323
// Setup the default locations for finding hosting configuration options
24-
// hosting.json, ASPNET_ prefixed env variables and command line arguments
24+
// hosting.json, ASPNETCORE_ prefixed env variables and command line arguments
2525
var configBuilder = new ConfigurationBuilder()
2626
.AddInMemoryCollection(defaultSettings)
2727
.AddJsonFile(WebHostDefaults.HostingJsonFile, optional: true)

src/Microsoft.AspNetCore.Hosting/Internal/WebHostOptions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ namespace Microsoft.AspNetCore.Hosting.Internal
88
{
99
public class WebHostOptions
1010
{
11-
private const string OldEnvironmentKey = "ENV";
12-
1311
public WebHostOptions()
1412
{
1513
}
@@ -24,7 +22,7 @@ public WebHostOptions(IConfiguration configuration)
2422
Application = configuration[WebHostDefaults.ApplicationKey];
2523
DetailedErrors = ParseBool(configuration, WebHostDefaults.DetailedErrorsKey);
2624
CaptureStartupErrors = ParseBool(configuration, WebHostDefaults.CaptureStartupErrorsKey);
27-
Environment = configuration[WebHostDefaults.EnvironmentKey] ?? configuration[OldEnvironmentKey];
25+
Environment = configuration[WebHostDefaults.EnvironmentKey];
2826
ServerFactoryLocation = configuration[WebHostDefaults.ServerKey];
2927
WebRoot = configuration[WebHostDefaults.WebRootKey];
3028
ApplicationBasePath = configuration[WebHostDefaults.ApplicationBaseKey];

src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public DeploymentParameters(
4343
ApplicationPath = applicationPath;
4444
ServerType = serverType;
4545
RuntimeFlavor = runtimeFlavor;
46-
EnvironmentVariables.Add(new KeyValuePair<string, string>("ASPNET_DETAILEDERRORS", "true"));
46+
EnvironmentVariables.Add(new KeyValuePair<string, string>("ASPNETCORE_DETAILEDERRORS", "true"));
4747
}
4848

4949
public ServerType ServerType { get; }

src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected void AddEnvironmentVariablesToProcess(ProcessStartInfo startInfo)
161161
startInfo.Environment;
162162
#endif
163163

164-
SetEnvironmentVariable(environment, "ASPNET_ENV", DeploymentParameters.EnvironmentName);
164+
SetEnvironmentVariable(environment, "ASPNETCORE_ENVIRONMENT", DeploymentParameters.EnvironmentName);
165165

166166
foreach (var environmentVariable in DeploymentParameters.EnvironmentVariables)
167167
{

test/Microsoft.AspNetCore.Hosting.Tests/WebHostConfigurationsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void ReadsParametersCorrectly()
4444
[Fact]
4545
public void ReadsOldEnvKey()
4646
{
47-
var parameters = new Dictionary<string, string>() { { "ENV", "Development" } };
47+
var parameters = new Dictionary<string, string>() { { "ENVIRONMENT", "Development" } };
4848
var config = new WebHostOptions(new ConfigurationBuilder().AddInMemoryCollection(parameters).Build());
4949

5050
Assert.Equal("Development", config.Environment);

test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,7 @@ public void EnvDefaultsToConfigValueIfSpecifiedWithOldKey()
282282
{
283283
var vals = new Dictionary<string, string>
284284
{
285-
// Old key is actualy ASPNET_ENV but WebHostConfiguration expects environment
286-
// variable names stripped from ASPNET_ prefix so using just ENV here
287-
{ "ENV", "Staging" }
285+
{ "environment", "Staging" }
288286
};
289287

290288
var builder = new ConfigurationBuilder()

0 commit comments

Comments
 (0)