diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs index 598fabb861..9fdfb3a76b 100644 --- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs +++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs @@ -437,10 +437,15 @@ private static void set_environment_options(ChocolateyConfiguration config) config.Information.IsProcessElevated = ProcessInformation.process_is_elevated(); } - public static void set_environment_variables(ChocolateyConfiguration config) + public static void reset_environment_variables(ChocolateyConfiguration config) { Environment.SetEnvironmentVariable("ChocolateyPackageInstallLocation", null); Environment.SetEnvironmentVariable("ChocolateyInstallerType", null); + } + + public static void set_environment_variables(ChocolateyConfiguration config) + { + reset_environment_variables(config); Environment.SetEnvironmentVariable(ApplicationParameters.ChocolateyInstallEnvironmentVariableName, ApplicationParameters.InstallLocation); Environment.SetEnvironmentVariable("CHOCOLATEY_VERSION", config.Information.ChocolateyVersion); diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 9c2df33a81..a2c4bc9b34 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -20,6 +20,7 @@ namespace chocolatey.infrastructure.app.services using System.Collections.Generic; using System.IO; using System.Linq; + using builders; using commandline; using configuration; using domain; @@ -271,6 +272,7 @@ public void randomly_notify_about_pro_business(ChocolateyConfiguration config, s public void handle_package_result(PackageResult packageResult, ChocolateyConfiguration config, CommandNameType commandName) { + ConfigurationBuilder.reset_environment_variables(config); set_pending(packageResult, config); var pkgInfo = _packageInfoService.get_package_information(packageResult.Package); if (config.AllowMultipleVersions)