Only add environment variables if we are running on win8.1 or above. (#1007)

This commit is contained in:
Justin Kotalik 2018-07-03 16:27:28 -07:00 committed by GitHub
parent 3efc1eede4
commit e7d36a42e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 5 deletions

View File

@ -198,19 +198,27 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
var pool = _serverManager.ApplicationPools.Add(AppPoolName);
pool.ProcessModel.IdentityType = ProcessModelIdentityType.LocalSystem;
pool.ManagedRuntimeVersion = string.Empty;
var envCollection = pool.GetCollection("environmentVariables");
AddEnvironmentVariables(contentRoot, envCollection);
AddEnvironmentVariables(contentRoot, pool);
_logger.LogInformation($"Configured AppPool {AppPoolName}");
return pool;
}
private void AddEnvironmentVariables(string contentRoot, ConfigurationElementCollection envCollection)
private void AddEnvironmentVariables(string contentRoot, ApplicationPool pool)
{
foreach (var tuple in _deploymentParameters.EnvironmentVariables)
try
{
AddEnvironmentVariableToAppPool(envCollection, tuple.Key, tuple.Value);
var envCollection = pool.GetCollection("environmentVariables");
foreach (var tuple in _deploymentParameters.EnvironmentVariables)
{
AddEnvironmentVariableToAppPool(envCollection, tuple.Key, tuple.Value);
}
}
catch (COMException comException)
{
_logger.LogInformation($"Could not add environment variables to worker process: {comException.Message}");
}
}