diff --git a/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 b/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1
index 7b6518c82a..c2f95b87a0 100644
Binary files a/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 and b/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 differ
diff --git a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj
index 83f2f1732a..e1765fb8f6 100644
--- a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj
+++ b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj
@@ -13,6 +13,7 @@
v4.0
512
..\
+ true
true
diff --git a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs
index 422bc53991..ef3bf5e7fb 100644
--- a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs
+++ b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs
@@ -344,7 +344,6 @@ public override void Context()
public override void Because()
{
- MockLogger.LogMessagesToConsole = true;
Results = Service.uninstall_run(Configuration);
_packageResult = Results.FirstOrDefault().Value;
}
diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs
index 74768d2ce2..0478b1552e 100644
--- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs
+++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs
@@ -28,6 +28,7 @@ namespace chocolatey.infrastructure.app.builders
using information;
using infrastructure.services;
using logging;
+ using nuget;
using platforms;
using tolerance;
using Environment = adapters.Environment;
@@ -64,6 +65,7 @@ public static void set_up_configuration(IList args, ChocolateyConfigurat
ConfigurationOptions.reset_options();
set_global_options(args, config);
set_environment_options(config);
+ set_environment_variables(config);
}
private static void set_file_configuration(ChocolateyConfiguration config, IFileSystem fileSystem, IXmlService xmlService, Action notifyWarnLoggingAction)
@@ -329,5 +331,50 @@ private static void set_environment_options(ChocolateyConfiguration config)
config.Information.IsUserAdministrator = ProcessInformation.user_is_administrator();
config.Information.IsProcessElevated = ProcessInformation.process_is_elevated();
}
+
+ public static void set_environment_variables(ChocolateyConfiguration config)
+ {
+ Environment.SetEnvironmentVariable(ApplicationParameters.ChocolateyInstallEnvironmentVariableName, ApplicationParameters.InstallLocation);
+ Environment.SetEnvironmentVariable("CHOCOLATEY_VERSION", config.Information.ChocolateyVersion);
+ Environment.SetEnvironmentVariable("CHOCOLATEY_VERSION_PRODUCT", config.Information.ChocolateyProductVersion);
+ Environment.SetEnvironmentVariable("OS_PLATFORM", config.Information.PlatformType.get_description_or_value());
+ Environment.SetEnvironmentVariable("OS_VERSION", config.Information.PlatformVersion.to_string());
+ Environment.SetEnvironmentVariable("OS_NAME", config.Information.PlatformName.to_string());
+ // experimental until we know if this value returns correctly based on the OS and not the current process.
+ Environment.SetEnvironmentVariable("OS_IS64BIT", config.Information.Is64Bit ? "true" : "false");
+ Environment.SetEnvironmentVariable("IS_ADMIN", config.Information.IsUserAdministrator ? "true" : "false");
+ Environment.SetEnvironmentVariable("IS_PROCESSELEVATED", config.Information.IsProcessElevated ? "true" : "false");
+
+ Environment.SetEnvironmentVariable("TEMP", config.CacheLocation);
+ if (config.Debug)
+ {
+ Environment.SetEnvironmentVariable("ChocolateyEnvironmentDebug", "true");
+ }
+ if (config.Verbose)
+ {
+ Environment.SetEnvironmentVariable("ChocolateyEnvironmentVerbose", "true");
+ }
+ if (!config.Features.CheckSumFiles)
+ {
+ Environment.SetEnvironmentVariable("ChocolateyIgnoreChecksums", "true");
+ }
+ if (!string.IsNullOrWhiteSpace(config.Proxy.Location))
+ {
+ var proxyCreds = string.Empty;
+ if (!string.IsNullOrWhiteSpace(config.Proxy.User) &&
+ !string.IsNullOrWhiteSpace(config.Proxy.EncryptedPassword)
+ )
+ {
+ proxyCreds = "{0}:{1}@".format_with(config.Proxy.User, NugetEncryptionUtility.DecryptString(config.Proxy.EncryptedPassword));
+
+ Environment.SetEnvironmentVariable("chocolateyProxyUser", config.Proxy.User);
+ Environment.SetEnvironmentVariable("chocolateyProxyPassword", NugetEncryptionUtility.DecryptString(config.Proxy.EncryptedPassword));
+ }
+
+ Environment.SetEnvironmentVariable("http_proxy", "{0}{1}".format_with(proxyCreds, config.Proxy.Location));
+ Environment.SetEnvironmentVariable("https_proxy", "{0}{1}".format_with(proxyCreds, config.Proxy.Location));
+ Environment.SetEnvironmentVariable("chocolateyProxyLocation", config.Proxy.Location);
+ }
+ }
}
}
diff --git a/src/chocolatey/infrastructure.app/services/PowershellService.cs b/src/chocolatey/infrastructure.app/services/PowershellService.cs
index 7bf14e29c1..cd5f7853b5 100644
--- a/src/chocolatey/infrastructure.app/services/PowershellService.cs
+++ b/src/chocolatey/infrastructure.app/services/PowershellService.cs
@@ -18,6 +18,7 @@ namespace chocolatey.infrastructure.app.services
using System.IO;
using System.Linq;
using adapters;
+ using builders;
using commandline;
using configuration;
using domain;
@@ -165,17 +166,10 @@ public bool run_action(ChocolateyConfiguration configuration, PackageResult pack
var failure = false;
+ //todo: this is here for any possible compatibility issues. Should be reviewed and removed.
+ ConfigurationBuilder.set_environment_variables(configuration);
+
var package = packageResult.Package;
- Environment.SetEnvironmentVariable(ApplicationParameters.ChocolateyInstallEnvironmentVariableName, ApplicationParameters.InstallLocation);
- Environment.SetEnvironmentVariable("CHOCOLATEY_VERSION", configuration.Information.ChocolateyVersion);
- Environment.SetEnvironmentVariable("CHOCOLATEY_VERSION_PRODUCT", configuration.Information.ChocolateyProductVersion);
- Environment.SetEnvironmentVariable("OS_PLATFORM", configuration.Information.PlatformType.get_description_or_value());
- Environment.SetEnvironmentVariable("OS_VERSION", configuration.Information.PlatformVersion.to_string());
- Environment.SetEnvironmentVariable("OS_NAME", configuration.Information.PlatformName.to_string());
- // experimental until we know if this value returns correctly based on the OS and not the current process.
- Environment.SetEnvironmentVariable("OS_IS64BIT", configuration.Information.Is64Bit ? "true" : "false");
- Environment.SetEnvironmentVariable("IS_ADMIN", configuration.Information.IsUserAdministrator ? "true" : "false");
- Environment.SetEnvironmentVariable("IS_PROCESSELEVATED", configuration.Information.IsProcessElevated ? "true" : "false");
Environment.SetEnvironmentVariable("chocolateyPackageName", package.Id);
Environment.SetEnvironmentVariable("packageName", package.Id);
Environment.SetEnvironmentVariable("chocolateyPackageVersion", package.Version.to_string());
@@ -195,42 +189,12 @@ public bool run_action(ChocolateyConfiguration configuration, PackageResult pack
{
Environment.SetEnvironmentVariable("chocolateyInstallOverride", "true");
}
-
- Environment.SetEnvironmentVariable("TEMP", configuration.CacheLocation);
-
+
if (configuration.NotSilent)
{
Environment.SetEnvironmentVariable("chocolateyInstallOverride", "true");
}
- if (configuration.Debug)
- {
- Environment.SetEnvironmentVariable("ChocolateyEnvironmentDebug", "true");
- }
- if (configuration.Verbose)
- {
- Environment.SetEnvironmentVariable("ChocolateyEnvironmentVerbose", "true");
- }
- if (!configuration.Features.CheckSumFiles)
- {
- Environment.SetEnvironmentVariable("ChocolateyIgnoreChecksums", "true");
- }
- if (!string.IsNullOrWhiteSpace(configuration.Proxy.Location))
- {
- var proxy_creds = string.Empty;
- if (!string.IsNullOrWhiteSpace(configuration.Proxy.User) &&
- !string.IsNullOrWhiteSpace(configuration.Proxy.EncryptedPassword)
- )
- {
- proxy_creds = "{0}:{1}@".format_with(configuration.Proxy.User, NugetEncryptionUtility.DecryptString(configuration.Proxy.EncryptedPassword));
-
- Environment.SetEnvironmentVariable("chocolateyProxyUser", configuration.Proxy.User);
- Environment.SetEnvironmentVariable("chocolateyProxyPassword", NugetEncryptionUtility.DecryptString(configuration.Proxy.EncryptedPassword));
- }
-
- Environment.SetEnvironmentVariable("http_proxy", "{0}{1}".format_with(proxy_creds, configuration.Proxy.Location));
- Environment.SetEnvironmentVariable("https_proxy", "{0}{1}".format_with(proxy_creds, configuration.Proxy.Location));
- Environment.SetEnvironmentVariable("chocolateyProxyLocation", configuration.Proxy.Location);
- }
+
//todo:if (configuration.NoOutput)
//{
// Environment.SetEnvironmentVariable("ChocolateyEnvironmentQuiet","true");
diff --git a/src/chocolatey/infrastructure/adapters/Environment.cs b/src/chocolatey/infrastructure/adapters/Environment.cs
index be5b5fca87..fa6b50b782 100644
--- a/src/chocolatey/infrastructure/adapters/Environment.cs
+++ b/src/chocolatey/infrastructure/adapters/Environment.cs
@@ -1,12 +1,12 @@
// Copyright © 2011 - Present RealDimensions Software, LLC
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
-//
+//
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,5 +43,10 @@ public string GetEnvironmentVariable(string variable)
{
return System.Environment.GetEnvironmentVariable(variable);
}
+
+ public void SetEnvironmentVariable(string variable, string value)
+ {
+ System.Environment.SetEnvironmentVariable(variable, value);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/chocolatey/infrastructure/adapters/IEnvironment.cs b/src/chocolatey/infrastructure/adapters/IEnvironment.cs
index 60549199a7..91eb0bbb23 100644
--- a/src/chocolatey/infrastructure/adapters/IEnvironment.cs
+++ b/src/chocolatey/infrastructure/adapters/IEnvironment.cs
@@ -1,12 +1,12 @@
// Copyright © 2011 - Present RealDimensions Software, LLC
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
-//
+//
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -69,7 +69,37 @@ public interface IEnvironment
/// The variable.
///
string GetEnvironmentVariable(string variable);
+
+ ///
+ /// Creates, modifies, or deletes an environment variable stored in the current process.
+ ///
+ ///
+ /// The name of an environment variable.
+ ///
+ ///
+ /// A value to assign to .
+ ///
+ ///
+ /// is null.
+ ///
+ ///
+ /// contains a zero-length string, an initial hexadecimal zero character (0x00), or an equal sign ("=").
+ /// -or-
+ /// The length of or is greater than or equal to 32,767 characters.
+ /// -or-
+ /// An error occurred during the execution of this operation.
+ ///
+ ///
+ /// The caller does not have the required permission to perform this operation.
+ ///
+ /// 1
+ ///
+ ///
+ ///
+ void SetEnvironmentVariable(string variable, string value);
}
// ReSharper restore InconsistentNaming
-}
\ No newline at end of file
+}