Skip to content

Commit

Permalink
(#2241) Set install location to package dir for portable packages
Browse files Browse the repository at this point in the history
Set the install location to the package folder under lib for nuget
packages that do not have a chocolateyinstall.ps1. This will display
the install location correctly for portable packages that just include
binary(s) that get automatically shimmed.
  • Loading branch information
TheCakeIsNaOH authored and gep13 committed Dec 23, 2021
1 parent b233116 commit 068abfa
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,17 @@ public virtual void handle_package_result(PackageResult packageResult, Chocolate

var pkgInfo = get_package_information(packageResult, config);

// initialize this here so it can be used for the install location later
bool powerShellRan = false;

if (packageResult.Success && config.Information.PlatformType == PlatformType.Windows)
{
if (!config.SkipPackageInstallProvider)
{
var installersBefore = _registryService.get_installer_keys();
var environmentBefore = get_environment_before(config, allowLogging: false);

var powerShellRan = _powershellService.install(config, packageResult);
powerShellRan = _powershellService.install(config, packageResult);
if (powerShellRan)
{
// we don't care about the exit code
Expand Down Expand Up @@ -413,6 +416,11 @@ public virtual void handle_package_result(PackageResult packageResult, Chocolate
}
}

if (!powerShellRan && string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(ApplicationParameters.Environment.ChocolateyPackageInstallLocation)))
{
Environment.SetEnvironmentVariable(ApplicationParameters.Environment.ChocolateyPackageInstallLocation, packageResult.InstallLocation, EnvironmentVariableTarget.Process);
}

if (pkgInfo.RegistrySnapshot != null && pkgInfo.RegistrySnapshot.RegistryKeys.Any(k => !string.IsNullOrWhiteSpace(k.InstallLocation)))
{
var key = pkgInfo.RegistrySnapshot.RegistryKeys.FirstOrDefault(k => !string.IsNullOrWhiteSpace(k.InstallLocation));
Expand Down

0 comments on commit 068abfa

Please sign in to comment.