diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index c8fd549a0c..69d99147e7 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -55,25 +55,25 @@ public class ChocolateyPackageService : IChocolateyPackageService private readonly IList _proBusinessMessages = new List { @" -Are you ready for the ultimate experience? Check out Pro / Business! +Are you ready for the ultimate experience? Check out Pro / Business! https://chocolatey.org/compare" , @" -Enjoy using Chocolatey? Explore more amazing features to take your +Enjoy using Chocolatey? Explore more amazing features to take your experience to the next level at https://chocolatey.org/compare" , @" -Did you know the proceeds of Pro (and some proceeds from other +Did you know the proceeds of Pro (and some proceeds from other licensed editions) go into bettering the community infrastructure? Your support ensures an active community, keeps Chocolatey tip top, - plus it nets you some awesome features! + plus it nets you some awesome features! https://chocolatey.org/compare", @" Did you know some organizations use Chocolatey completely internally without using the community repository or downloads from the internet? Wait until you see how Package Builder and Package Internalizer can - help you achieve more, quicker and easier! Get your trial started + help you achieve more, quicker and easier! Get your trial started today at https://chocolatey.org/compare", @" An organization needed total software management life cycle automation. @@ -81,19 +81,19 @@ An organization needed total software management life cycle automation. next! https://chocolatey.org/compare", @" -Did you know that Package Synchronizer and AutoUninstaller enhancements - in licensed versions are up to 95% effective in removing system +Did you know that Package Synchronizer and AutoUninstaller enhancements + in licensed versions are up to 95% effective in removing system installed software without an uninstall script? Find out more at https://chocolatey.org/compare", @" Did you know Chocolatey goes to eleven? And it turns great developers / - system admins into something amazing! Singlehandedly solve your + system admins into something amazing! Singlehandedly solve your organization's struggles with software management and save the day! https://chocolatey.org/compare" }; private const string PRO_BUSINESS_LIST_MESSAGE = @" Did you know Pro / Business automatically syncs with Programs and - Features? Learn more about Package Synchronizer at + Features? Learn more about Package Synchronizer at https://chocolatey.org/compare"; private readonly string _shutdownExe = Environment.ExpandEnvironmentVariables("%systemroot%\\System32\\shutdown.exe"); @@ -163,7 +163,7 @@ public IEnumerable list_run(ChocolateyConfiguration config) { if (string.IsNullOrWhiteSpace(config.Sources)) { - this.Log().Error(ChocolateyLoggers.Important, @"Unable to search for packages when there are no sources enabled for + this.Log().Error(ChocolateyLoggers.Important, @"Unable to search for packages when there are no sources enabled for packages and none were passed as arguments."); Environment.ExitCode = 1; yield break; @@ -381,6 +381,9 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu //review: is this a Windows only kind of thing? pkgInfo.FilesSnapshot = _filesService.capture_package_files(packageResult, config); + var is32Bit = !config.Information.Is64BitProcess || config.ForceX86; + create_ignore_files_for_executables(packageResult.InstallLocation, !is32Bit); + if (packageResult.Success) _shimgenService.install(config, packageResult); } else @@ -446,11 +449,31 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu } else { - this.Log().Info(ChocolateyLoggers.Important, @" Software install location not explicitly set, could be in package or + this.Log().Info(ChocolateyLoggers.Important, @" Software install location not explicitly set, could be in package or default install location if installer."); } } + private void create_ignore_files_for_executables(string installLocation, bool is64Bit) + { + // If we are using a 64 bit architecure, we want to ignore exe's targetting x86 + // This is done by adding a .ignore file into the package folder for each exe to ignore + var exeFiles32Bit = _fileSystem.get_files(_fileSystem.combine_paths(installLocation, "tools\\x86"), pattern: "*.exe", option: SearchOption.AllDirectories).ToArray(); + var exeFiles64Bit = _fileSystem.get_files(_fileSystem.combine_paths(installLocation, "tools\\x64"), pattern: "*.exe", option: SearchOption.AllDirectories).ToArray(); + + // If 64bit, and there are only 32bit files, we should shim the 32bit versions, + // therefore, don't ignore anything + if (!exeFiles64Bit.Any() && exeFiles32Bit.Any() && is64Bit) + { + return; + } + + foreach (var exeFile in is64Bit ? exeFiles32Bit : exeFiles64Bit) + { + _fileSystem.create_file(exeFile + ".ignore"); + } + } + protected virtual ChocolateyPackageInformation get_package_information(PackageResult packageResult, ChocolateyConfiguration config) { var pkgInfo = _packageInfoService.get_package_information(packageResult.Package); @@ -527,7 +550,7 @@ public ConcurrentDictionary install_run(ChocolateyConfigu if (string.IsNullOrWhiteSpace(config.Sources)) { - this.Log().Error(ChocolateyLoggers.Important, @"Installation was NOT successful. There are no sources enabled for + this.Log().Error(ChocolateyLoggers.Important, @"Installation was NOT successful. There are no sources enabled for packages and none were passed as arguments."); Environment.ExitCode = 1; return packageInstalls; @@ -567,7 +590,7 @@ public ConcurrentDictionary install_run(ChocolateyConfigu public void outdated_noop(ChocolateyConfiguration config) { this.Log().Info(@" -Would have determined packages that are out of date based on what is +Would have determined packages that are out of date based on what is installed and what versions are available for upgrade."); } @@ -704,7 +727,7 @@ public ConcurrentDictionary upgrade_run(ChocolateyConfigu if (string.IsNullOrWhiteSpace(config.Sources)) { - this.Log().Error(ChocolateyLoggers.Important, @"Upgrading was NOT successful. There are no sources enabled for + this.Log().Error(ChocolateyLoggers.Important, @"Upgrading was NOT successful. There are no sources enabled for packages and none were passed as arguments."); Environment.ExitCode = 1; return new ConcurrentDictionary(); @@ -798,17 +821,17 @@ public ConcurrentDictionary uninstall_run(ChocolateyConfi { this.Log().Warn(@" If a package uninstall is failing and/or you've already uninstalled the - software outside of Chocolatey, you can attempt to run the command + software outside of Chocolatey, you can attempt to run the command with `-n` to skip running a chocolateyUninstall script, additionally - adding `--skip-autouninstaller` to skip an attempt to automatically - remove system-installed software. This will only remove the packaging + adding `--skip-autouninstaller` to skip an attempt to automatically + remove system-installed software. This will only remove the packaging files and not things like software installed to Programs and Features. If a package is failing because it is a dependency of another package or packages, then you may first need to consider if it needs removed - as it is typically installed as a dependency for a reason. If you - decide that you still want to remove it, head into - `$env:ChocolateyInstall\lib` and find the package folder you want + as it is typically installed as a dependency for a reason. If you + decide that you still want to remove it, head into + `$env:ChocolateyInstall\lib` and find the package folder you want removed. Then delete the folder for the package. This option should only be used as a last resort. "); @@ -867,7 +890,7 @@ private int report_action_summary(ConcurrentDictionary pa this.Log().Warn(" - {0}{1}".format_with(reboot.Value.Name, reboot.Value.ExitCode != 0 ? " (exit code {0})".format_with(reboot.Value.ExitCode) : string.Empty)); } this.Log().Warn(ChocolateyLoggers.Important, @" -The recent package changes indicate a reboot is necessary. +The recent package changes indicate a reboot is necessary. Please reboot at your earliest convenience."); } @@ -1121,11 +1144,11 @@ private void handle_unsuccessful_operation(ChocolateyConfiguration config, Packa { this.Log().Error(ChocolateyLoggers.Important, @" Package location is not specific enough, cannot move bad package or - rollback previous version. Erroneous install location captured as + rollback previous version. Erroneous install location captured as '{0}' -ATTENTION: You must take manual action to remove {1} from - {2}. It will show incorrectly as installed +ATTENTION: You must take manual action to remove {1} from + {2}. It will show incorrectly as installed until you do. To remove you can simply delete the folder in question. ".format_with(packageResult.InstallLocation, packageResult.Name, ApplicationParameters.PackagesLocation)); } @@ -1303,7 +1326,7 @@ private void get_log_environment_changes(ChocolateyConfiguration config, IEnumer if (!config.Features.LogEnvironmentValues) { - this.Log().Debug(@"Logging of values is not turned on by default because it + this.Log().Debug(@"Logging of values is not turned on by default because it could potentially expose sensitive data. If you understand the risk, please see `choco feature -h` for information to turn it on."); }