From e584f0fa1b8ffbd372a17e3b38a36a28cb356922 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Mon, 30 May 2016 21:56:03 -0500 Subject: [PATCH] (GH-689) Report install work w/non-POSH pkgs If a package is a dependency or has no PowerShell, it should still clean up env vars between the two packages. --- .../infrastructure.app/builders/ConfigurationBuilder.cs | 7 ++++++- .../services/ChocolateyPackageService.cs | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) 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)