From e7d36a42e6b7b96451e38c6142445fe0371c1f91 Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Tue, 3 Jul 2018 16:27:28 -0700 Subject: [PATCH] Only add environment variables if we are running on win8.1 or above. (#1007) --- .../Utilities/IISApplication.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/IISIntegration.FunctionalTests/Utilities/IISApplication.cs b/test/IISIntegration.FunctionalTests/Utilities/IISApplication.cs index 013c24e376..faba405c06 100644 --- a/test/IISIntegration.FunctionalTests/Utilities/IISApplication.cs +++ b/test/IISIntegration.FunctionalTests/Utilities/IISApplication.cs @@ -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}"); } }