From 002db2798782ea2f8cba7b30a715605a8bef1a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Lipt=C3=A1k?= Date: Fri, 9 Apr 2021 12:45:01 -0400 Subject: [PATCH 01/17] (#2227) Use latest Mono and Ubuntu on Travis When building the chocolatey code base on Travis, there is a failure when trying to restore nuget packages. This is due to the fact that an older version of Mono doesn't contain the newer root certificates necessary to ensure a valid TLS handshake. Using a newer version of Mono ensures that these are in place. In addition, updating to the latest Ubuntu (bionic). --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bf92067bca..e1f2471ade 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: csharp +dist: bionic mono: - - 5.20.1 + - 6.12.0 install: - sudo apt-get install mono-devel - nuget restore src/chocolatey.sln From de5b853561aed64a772bac9cc275b99a9eb0adbf Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 14 Apr 2021 08:10:03 +0100 Subject: [PATCH 02/17] (#2078) Skip importing Chocolatey GUI Extension The Chocolatey GUI Extension is a "special" extension in the sense that it isn't intended to work with Chocolatey directly, but it is shipped as a "normal" Chocolatey extension. We don't want to load the chocolateygui.licensed.dll into the choco.exe process, but rather leave it alone, and allow Chocolatey GUI to load it when required. --- src/chocolatey.resources/helpers/chocolateyInstaller.psm1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 index 71ce959713..aaf003a8aa 100644 --- a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 +++ b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 @@ -1,4 +1,4 @@ -# Copyright © 2017 Chocolatey Software, Inc. +# Copyright © 2017 Chocolatey Software, Inc. # Copyright © 2015 - 2017 RealDimensions Software, LLC # Copyright © 2011 - 2015 RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey # @@ -73,7 +73,11 @@ if (Test-Path($extensionsPath)) { } } - if (!$loaded) { Import-Module $path; } + if (!$loaded) { + if ($fileNameWithoutExtension -ne "chocolateygui.licensed") { + Import-Module $path; + } + } } catch { if ($env:ChocolateyPowerShellHost -eq 'true') { Write-Warning "Import failed for '$path'. Error: '$_'" From 3f40ef4345776330f89ffe24014206120574065f Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 16 Apr 2021 13:10:17 +0100 Subject: [PATCH 03/17] (maint) Replace tabs with spaces The file predominately uses spaces, so remove the tabs to makes things consistent. --- .../helpers/chocolateyInstaller.psm1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 index aaf003a8aa..c915808b71 100644 --- a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 +++ b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 @@ -40,11 +40,11 @@ Write-Debug "Host version is $($host.Version), PowerShell Version is '$($PSVersi Get-Item $helpersPath\functions\*.ps1 | ? { -not ($_.Name.Contains(".Tests.")) } | % { - . $_.FullName; - #Export-ModuleMember -Function $_.BaseName + . $_.FullName; + #Export-ModuleMember -Function $_.BaseName } -# Export built-in functions prior to loading extensions so that +# Export built-in functions prior to loading extensions so that # extension-specific loading behavior can be used based on built-in # functions. This allows those overrides to be much more deterministic # This behavior was broken from v0.9.9.5 - v0.10.3. @@ -66,14 +66,14 @@ if (Test-Path($extensionsPath)) { Write-Debug "Loading '$fileNameWithoutExtension' extension."; $loaded = $false $currentAssemblies | % { - $name = $_.GetName().Name - if ($name -eq $fileNameWithoutExtension) { - Import-Module $_ - $loaded = $true + $name = $_.GetName().Name + if ($name -eq $fileNameWithoutExtension) { + Import-Module $_ + $loaded = $true } - } + } - if (!$loaded) { + if (!$loaded) { if ($fileNameWithoutExtension -ne "chocolateygui.licensed") { Import-Module $path; } From 1b67b523fdeb3d4bfe1e9b7d4ee428fb8ef7e2ee Mon Sep 17 00:00:00 2001 From: Peter Ritchie Date: Fri, 27 Nov 2020 14:09:07 -0700 Subject: [PATCH 04/17] (maint) Spelling and grammar fixes I noticed _it could be in package or default install location *if* installer_. and changed to _it could be in package or default install location of installer_. Then found a few more grammar and spelling opportunities. --- .../services/ChocolateyPackageService.cs | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 0b4295d93d..c378c2a314 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -66,14 +66,14 @@ experience to the next level at @" 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, + Your support ensures an active community, keeps Chocolatey tip-top, 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. @@ -338,7 +338,7 @@ public virtual void handle_package_result(PackageResult packageResult, Chocolate EnvironmentSettings.reset_environment_variables(config); set_pending(packageResult, config); - this.Log().Info("{0} package files {1} completed. Performing other installation steps.".format_with(packageResult.Name, commandName.to_string())); + this.Log().Info("{0} package files {1} completed. Continuing, performing other installation steps.".format_with(packageResult.Name, commandName.to_string())); var pkgInfo = get_package_information(packageResult, config); @@ -433,7 +433,7 @@ public virtual void handle_package_result(PackageResult packageResult, Chocolate this.Log().Warn(ChocolateyLoggers.Important, @"Chocolatey has detected a pending reboot after installing/upgrading package '{0}' - stopping further execution".format_with(packageResult.Name)); - throw new ApplicationException("Reboot required before continuing. Reboot and run same command again."); + throw new ApplicationException("Reboot required before continuing. Reboot and run the same command again."); } } @@ -466,8 +466,8 @@ public virtual void handle_package_result(PackageResult packageResult, Chocolate } else { - this.Log().Info(ChocolateyLoggers.Important, @" Software install location not explicitly set, could be in package or - default install location if installer."); + this.Log().Info(ChocolateyLoggers.Important, @" Software install location not explicitly set, it could be in package or + default install location of installer."); } } @@ -568,12 +568,12 @@ public virtual ConcurrentDictionary install_run(Chocolate if (string.IsNullOrWhiteSpace(config.Sources)) { this.Log().Error(ChocolateyLoggers.Important, @"Installation was NOT successful. There are no sources enabled for - packages and none were passed as arguments."); + packages, and none were passed as arguments."); Environment.ExitCode = 1; return packageInstalls; } - this.Log().Info(@"By installing you accept licenses for the packages."); + this.Log().Info(@"By installing, you accept licenses for the packages."); get_environment_before(config, allowLogging: true); @@ -697,7 +697,7 @@ private IEnumerable get_packages_from_config(string pac if (!_fileSystem.file_exists(_fileSystem.get_full_path(packageConfigFile))) { - var logMessage = "Could not find '{0}' in the location specified.".format_with(packageConfigFile); + var logMessage = "'{0}' could not be found in the location specified.".format_with(packageConfigFile); this.Log().Error(ChocolateyLoggers.Important, logMessage); var results = packageInstalls.GetOrAdd(packageConfigFile, new PackageResult(packageConfigFile, null, null)); results.Messages.Add(new ResultMessage(ResultType.Error, logMessage)); @@ -761,7 +761,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate return new ConcurrentDictionary(); } - this.Log().Info(@"By upgrading you accept licenses for the packages."); + this.Log().Info(@"By upgrading, you accept licenses for the packages."); foreach (var packageConfigFile in config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().Where(p => p.EndsWith(".config")).ToList()) { @@ -875,16 +875,16 @@ If a package uninstall is failing and/or you've already uninstalled the 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 - files and not things like software installed to Programs and Features. + remove system-installed software. Only the packaging files are removed + 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 - removed. Then delete the folder for the package. This option should - only be used as a last resort. + or packages, then you may first need to consider if it needs to be + removed as packages have dependencies 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 to + be removed. Then delete the folder for the package. You should use + this option only as a last resort. "); } @@ -1006,7 +1006,7 @@ public virtual void handle_package_uninstall(PackageResult packageResult, Chocol this.Log().Warn(ChocolateyLoggers.Important, @"Chocolatey has detected a pending reboot after uninstalling package '{0}' - stopping further execution".format_with(packageResult.Name)); - throw new ApplicationException("Reboot required before continuing. Reboot and run same command again."); + throw new ApplicationException("Reboot required before continuing. Reboot and run the same command again."); } } @@ -1208,12 +1208,12 @@ 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 the 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 - until you do. To remove you can simply delete the folder in question. + until you do. To remove, you can simply delete the folder in question. ".format_with(packageResult.InstallLocation, packageResult.Name, ApplicationParameters.PackagesLocation)); } else @@ -1233,7 +1233,7 @@ private void move_bad_package_to_failure_location(PackageResult packageResult) { FaultTolerance.try_catch_with_logging_exception( () => _fileSystem.move_directory(packageResult.InstallLocation, packageResult.InstallLocation.Replace(ApplicationParameters.PackagesLocation, ApplicationParameters.PackageFailuresLocation)), - "Could not move bad package to failure directory It will show as installed.{0} {1}{0} The error".format_with(Environment.NewLine, packageResult.InstallLocation)); + "Could not move the bad package to the failure directory. It will show as installed.{0} {1}{0} The error".format_with(Environment.NewLine, packageResult.InstallLocation)); } } From 4dc9b50ecfb331b4750ffb36697c4b21424aec67 Mon Sep 17 00:00:00 2001 From: GankousKhan Date: Thu, 1 Oct 2020 17:16:21 -0400 Subject: [PATCH 05/17] (GH-2048) update deprecation note to outdated --- .../infrastructure.app/commands/ChocolateyVersionCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyVersionCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyVersionCommand.cs index 5091cd474d..5d96007959 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyVersionCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyVersionCommand.cs @@ -84,7 +84,7 @@ DEPRECATION NOTICE - `choco version -lo` is deprecated. version command { this.Log().Warn(ChocolateyLoggers.Important, @" DEPRECATION NOTICE - choco version command is deprecated and will be - removed in version 1.0.0. Please use `choco upgrade pkgname --noop` + removed in version 1.0.0. Please use `choco outdated` instead."); } From fe95f1c4801b59f6a632951fc00cf5a25fcab6a9 Mon Sep 17 00:00:00 2001 From: DdOtzen Date: Fri, 11 Sep 2020 08:23:22 +0200 Subject: [PATCH 06/17] (#2114) Remove unused variable As discussed in https://github.com/chocolatey/choco/issues/2114#issuecomment-690764825 --- .../infrastructure.app/templates/ChocolateyUninstallTemplate.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs b/src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs index d0ead8f27f..8b96826c37 100644 --- a/src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs +++ b/src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs @@ -55,7 +55,6 @@ public class ChocolateyUninstallTemplate #validExitCodes= @(0) #please insert other valid exit codes here } -$uninstalled = $false # Get-UninstallRegistryKey is new to 0.9.10, if supporting 0.9.9.x and below, # take a dependency on ""chocolatey-core.extension"" in your nuspec file. # This is only a fuzzy search if $softwareName includes '*'. Otherwise it is From e89ee921ee863f6766b6aeaa140ff34bd7f6dc57 Mon Sep 17 00:00:00 2001 From: Taras Petruk Date: Sun, 28 Jul 2019 19:29:15 +0300 Subject: [PATCH 07/17] (GH-1889) Fix: Removal of ApiKey broken `remove_api_key` was previously not working properly. The API key string did not get removed from the config file due to incorrect implementation of Equals method in ConfigFileApiKeySettings class. Current commit fixes this issue. --- .../infrastructure.app/configuration/ConfigFileApiKeySetting.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/configuration/ConfigFileApiKeySetting.cs b/src/chocolatey/infrastructure.app/configuration/ConfigFileApiKeySetting.cs index 6913328737..e2a9237bf4 100644 --- a/src/chocolatey/infrastructure.app/configuration/ConfigFileApiKeySetting.cs +++ b/src/chocolatey/infrastructure.app/configuration/ConfigFileApiKeySetting.cs @@ -43,7 +43,7 @@ public override bool Equals(object obj) var item = (ConfigFileApiKeySetting) obj; return (Source == item.Source) - && (Key == item.Source); + && (Key == item.Key); } public override int GetHashCode() From bef0b8994e997fc210f2a83f9b57e78ffb1840cd Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Mon, 22 Feb 2021 19:23:37 -0600 Subject: [PATCH 08/17] (GH-2203) Get-ChocolateyUnzip add unzipLocation alias Install-ChocolateyZipPackage already has a Destination alias to UnzipLocation. This adds the inverse case, so Get-ChocolateyUnzip has an alias UnzipLocation to the Destination parameter. The reason for adding this is to reduce frustration from adding the wrong parameter name, and then having to fix it. --- .../helpers/functions/Get-ChocolateyUnzip.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 b/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 index 944c9ff864..1a47f97815 100644 --- a/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 @@ -88,7 +88,7 @@ Install-ChocolateyZipPackage #> param( [alias("file")][parameter(Mandatory=$false, Position=0)][string] $fileFullPath, - [parameter(Mandatory=$true, Position=1)][string] $destination, + [alias("unzipLocation")][parameter(Mandatory=$true, Position=1)][string] $destination, [parameter(Mandatory=$false, Position=2)][string] $specificFolder, [parameter(Mandatory=$false, Position=3)][string] $packageName, [alias("file64")][parameter(Mandatory=$false)][string] $fileFullPath64, From f6530e4045b05dfe6a2b0baeafa9c730c83594e1 Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Thu, 25 Mar 2021 14:32:24 +0100 Subject: [PATCH 09/17] (#1866) Limit pending package removal to top level Previously, Chocolatey would search all sub directories when trying to remove pending packages as part of other commands. This was causing several second execution times when sub directories were large and/or symlinked on a network drive. By restricting the cleanup to the top directory only, the command execution times will be much more consistent. Co-authored-by: Tim Guenthner --- .../infrastructure.app/tasks/RemovePendingPackagesTask.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chocolatey/infrastructure.app/tasks/RemovePendingPackagesTask.cs b/src/chocolatey/infrastructure.app/tasks/RemovePendingPackagesTask.cs index b2e85bc4ef..bc50d12a91 100644 --- a/src/chocolatey/infrastructure.app/tasks/RemovePendingPackagesTask.cs +++ b/src/chocolatey/infrastructure.app/tasks/RemovePendingPackagesTask.cs @@ -60,13 +60,13 @@ private void handle_message(PreRunMessage message) { this.Log().Debug(ChocolateyLoggers.Verbose, "[Pending] Removing all pending packages that should not be considered installed..."); - var pendingFiles = _fileSystem.get_files(ApplicationParameters.PackagesLocation, ApplicationParameters.PackagePendingFileName, SearchOption.AllDirectories).ToList(); + var pendingFiles = _fileSystem.get_files(ApplicationParameters.PackagesLocation, ApplicationParameters.PackagePendingFileName).ToList(); foreach (var pendingFile in pendingFiles.or_empty_list_if_null()) { var packageFolder = _fileSystem.get_directory_name(pendingFile); string packageFolderName = _fileSystem.get_directory_info_for(packageFolder).Name; - var pendingSkipFiles = _fileSystem.get_files(packageFolder, PENDING_SKIP_FILE, SearchOption.AllDirectories).ToList(); + var pendingSkipFiles = _fileSystem.get_files(packageFolder, PENDING_SKIP_FILE).ToList(); if (pendingSkipFiles.Count != 0) { this.Log().Warn("Pending file found for {0}, but a {1} file was also found. Skipping removal".format_with(packageFolderName, PENDING_SKIP_FILE)); From 21e8d77c34c4f036bccfbe5ded532b4529e230db Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Mon, 8 Jun 2020 15:38:29 -0500 Subject: [PATCH 10/17] (GH-1364) Template create .nuspec encoded without BOM Changes the encoding of `.nuspec` files created from templates to UTF8 with BOM to UTF8 without BOM according to best practices in the creating packages documentation. Applies to both the default template and to custom templates. Adjusted template services tests to include UTF8 no BOM files, otherwise nuspec files would not be detected anymore. --- .../services/TemplateServiceSpecs.cs | 6 ++++++ .../infrastructure.app/services/TemplateService.cs | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs index fb9f9f9659..1ca436debe 100644 --- a/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs @@ -231,6 +231,7 @@ public class when_generate_is_called : TemplateServiceSpecsBase private readonly ChocolateyConfiguration config = new ChocolateyConfiguration(); private readonly List files = new List(); private readonly HashSet directoryCreated = new HashSet(StringComparer.InvariantCultureIgnoreCase); + private readonly UTF8Encoding utf8WithoutBOM = new UTF8Encoding(false); public override void Context() { @@ -250,6 +251,8 @@ public override void Context() fileSystem.Setup(x => x.directory_exists(It.IsAny())).Returns(dirPath => dirPath.EndsWith("templates\\default")); fileSystem.Setup(x => x.write_file(It.IsAny(), It.IsAny(), Encoding.UTF8)) .Callback((string filePath, string fileContent, Encoding encoding) => files.Add(filePath)); + fileSystem.Setup(x => x.write_file(It.IsAny(), It.IsAny(), utf8WithoutBOM)) + .Callback((string filePath, string fileContent, Encoding encoding) => files.Add(filePath)); fileSystem.Setup(x => x.delete_directory_if_exists(It.IsAny(), true)); fileSystem.Setup(x => x.create_directory_if_not_exists(It.IsAny())).Callback( (string directory) => @@ -322,6 +325,7 @@ public class when_generate_is_called_with_nested_folders : TemplateServiceSpecsB private readonly ChocolateyConfiguration config = new ChocolateyConfiguration(); private readonly List files = new List(); private readonly HashSet directoryCreated = new HashSet(StringComparer.InvariantCultureIgnoreCase); + private readonly UTF8Encoding utf8WithoutBOM = new UTF8Encoding(false); public override void Context() { @@ -341,6 +345,8 @@ public override void Context() fileSystem.Setup(x => x.directory_exists(It.IsAny())).Returns(dirPath => dirPath.EndsWith("templates\\test")); fileSystem.Setup(x => x.write_file(It.IsAny(), It.IsAny(), Encoding.UTF8)) .Callback((string filePath, string fileContent, Encoding encoding) => files.Add(filePath)); + fileSystem.Setup(x => x.write_file(It.IsAny(), It.IsAny(), utf8WithoutBOM)) + .Callback((string filePath, string fileContent, Encoding encoding) => files.Add(filePath)); fileSystem.Setup(x => x.delete_directory_if_exists(It.IsAny(), true)); fileSystem.Setup(x => x.get_files(It.IsAny(), "*.*", SearchOption.AllDirectories)) .Returns(new[] { "templates\\test\\template.nuspec", "templates\\test\\random.txt", "templates\\test\\tools\\chocolateyInstall.ps1", "templates\\test\\tools\\lower\\another.ps1" }); diff --git a/src/chocolatey/infrastructure.app/services/TemplateService.cs b/src/chocolatey/infrastructure.app/services/TemplateService.cs index 3c5095e267..a91c3b72e3 100644 --- a/src/chocolatey/infrastructure.app/services/TemplateService.cs +++ b/src/chocolatey/infrastructure.app/services/TemplateService.cs @@ -29,6 +29,7 @@ namespace chocolatey.infrastructure.app.services public class TemplateService : ITemplateService { + private readonly UTF8Encoding utf8WithoutBOM = new UTF8Encoding(false); private readonly IFileSystem _fileSystem; private readonly IList _templateBinaryExtensions = new List { ".exe", ".msi", ".msu", ".msp", ".mst", @@ -104,7 +105,7 @@ public void generate(ChocolateyConfiguration configuration) var defaultTemplateOverride = _fileSystem.combine_paths(ApplicationParameters.TemplatesLocation, "default"); if (string.IsNullOrWhiteSpace(configuration.NewCommand.TemplateName) && (!_fileSystem.directory_exists(defaultTemplateOverride) || configuration.NewCommand.UseOriginalTemplate)) { - generate_file_from_template(configuration, tokens, NuspecTemplate.Template, _fileSystem.combine_paths(packageLocation, "{0}.nuspec".format_with(tokens.PackageNameLower)), Encoding.UTF8); + generate_file_from_template(configuration, tokens, NuspecTemplate.Template, _fileSystem.combine_paths(packageLocation, "{0}.nuspec".format_with(tokens.PackageNameLower)), utf8WithoutBOM); generate_file_from_template(configuration, tokens, ChocolateyInstallTemplate.Template, _fileSystem.combine_paths(packageToolsLocation, "chocolateyinstall.ps1"), Encoding.UTF8); generate_file_from_template(configuration, tokens, ChocolateyBeforeModifyTemplate.Template, _fileSystem.combine_paths(packageToolsLocation, "chocolateybeforemodify.ps1"), Encoding.UTF8); generate_file_from_template(configuration, tokens, ChocolateyUninstallTemplate.Template, _fileSystem.combine_paths(packageToolsLocation, "chocolateyuninstall.ps1"), Encoding.UTF8); @@ -125,9 +126,13 @@ public void generate(ChocolateyConfiguration configuration) { var packageFileLocation = file.Replace(templatePath, packageLocation); var fileExtension = _fileSystem.get_file_extension(packageFileLocation); - if (fileExtension.is_equal_to(".nuspec")) packageFileLocation = _fileSystem.combine_paths(packageLocation, "{0}.nuspec".format_with(tokens.PackageNameLower)); - if (_templateBinaryExtensions.Contains(fileExtension)) + if (fileExtension.is_equal_to(".nuspec")) + { + packageFileLocation = _fileSystem.combine_paths(packageLocation, "{0}.nuspec".format_with(tokens.PackageNameLower)); + generate_file_from_template(configuration, tokens, _fileSystem.read_file(file), packageFileLocation, utf8WithoutBOM); + } + else if (_templateBinaryExtensions.Contains(fileExtension)) { this.Log().Debug(" Treating template file ('{0}') as binary instead of replacing templated values.".format_with(_fileSystem.get_file_name(file))); _fileSystem.copy_file(file, packageFileLocation, overwriteExisting:true); From f13e94601064f5633a5b74d1151ac5de588ea192 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 18 Jul 2018 10:37:26 +0100 Subject: [PATCH 11/17] (GH-2092) Take all registry keys into account It is possible that the installation of an application can generate multiple registry keys within the snapshot file that is craeted. Rather than looking at only the first registry key when deciding if an installed application is covered by a Chocolatey package, look at all keys within the snapshot file. --- .../services/ChocolateyPackageService.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index c378c2a314..f40e9735ee 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -210,16 +210,14 @@ public virtual IEnumerable list_run(ChocolateyConfiguration confi private IEnumerable report_registry_programs(ChocolateyConfiguration config, IEnumerable list) { - var itemsToRemoveFromMachine = list.Select(package => _packageInfoService.get_package_information(package)). - Where(p => p.RegistrySnapshot != null). - Select(p => p.RegistrySnapshot.RegistryKeys.FirstOrDefault()). - Where(p => p != null). - Select(p => p.DisplayName).ToList(); + var itemsToRemoveFromMachine = list.Select(package => _packageInfoService.get_package_information(package)).Where(p => p.RegistrySnapshot != null).ToList(); var count = 0; - var machineInstalled = _registryService.get_installer_keys().RegistryKeys. - Where((p) => p.is_in_programs_and_features() && !itemsToRemoveFromMachine.Contains(p.DisplayName) && !p.KeyPath.contains("choco-")). - OrderBy((p) => p.DisplayName).Distinct(); + var machineInstalled = _registryService.get_installer_keys().RegistryKeys.Where( + p => p.is_in_programs_and_features() && + !itemsToRemoveFromMachine.Any(pkg => pkg.RegistrySnapshot.RegistryKeys.Any(k => k.DisplayName.is_equal_to(p.DisplayName))) && + !p.KeyPath.contains("choco-")).OrderBy(p => p.DisplayName).Distinct(); + this.Log().Info(() => ""); foreach (var key in machineInstalled) { From 95eae5ad36fe44fb9923fceb41ded6e5663c5bf3 Mon Sep 17 00:00:00 2001 From: Mauville <40512475+Mauville@users.noreply.github.com> Date: Sun, 16 Jun 2019 14:57:22 -0500 Subject: [PATCH 12/17] (maint) Improve log message The log message when trying to downgrade a program shows a variety of switches, --force, --allow-downgrade One of these is formatted as prose, side by side Changed to reflect proper switch syntax. --- src/chocolatey/infrastructure.app/services/NugetService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 95a20a6129..35ecc269ac 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -464,7 +464,7 @@ public virtual ConcurrentDictionary install_run(Chocolate if (installedPackage != null && version != null && version < installedPackage.Version && !config.AllowMultipleVersions && !config.AllowDowngrade) { - string logMessage = "A newer version of {0} (v{1}) is already installed.{2} Use --allow-downgrade or --force to attempt to install older versions, or use side by side to allow multiple versions.".format_with(installedPackage.Id, installedPackage.Version, Environment.NewLine); + string logMessage = "A newer version of {0} (v{1}) is already installed.{2} Use --allow-downgrade or --force to attempt to install older versions, or use --side-by-side to allow multiple versions.".format_with(installedPackage.Id, installedPackage.Version, Environment.NewLine); var nullResult = packageInstalls.GetOrAdd(packageName, new PackageResult(installedPackage, _fileSystem.combine_paths(ApplicationParameters.PackagesLocation, installedPackage.Id))); nullResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage)); this.Log().Error(ChocolateyLoggers.Important, logMessage); @@ -1637,4 +1637,4 @@ private void set_package_names_if_all_is_specified(ChocolateyConfiguration confi } } } -} \ No newline at end of file +} From 4c3cf9c6a548322905b1afe20b8bbd5e47244d6f Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Fri, 27 Oct 2017 18:12:51 +1030 Subject: [PATCH 13/17] (GH-1060) Add BeforeInstall parameter to Install-ChocolateyPackage.ps1 - Add a ScriptBlock parameter `BeforeInstall` to Install-ChocolateyPackage.ps1. If supplied, the script block is called after download but before install. --- .../helpers/functions/Install-ChocolateyPackage.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 index 9131d0f2b3..030c198de1 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 @@ -220,6 +220,13 @@ functionality (see links). .PARAMETER IgnoredArguments Allows splatting with arguments that do not apply. Do not use directly. +.PARAMETER BeforeInstall Script +Specifies the commands to run after download has completed but before install steps have begun. +Available in 0.10.16+. + +Use this for starting an auxilary process such as AutoHotkey, so that any timeouts are not +affected by the time to download. + .EXAMPLE > $packageName= 'bob' @@ -359,6 +366,7 @@ param( [parameter(Mandatory=$false)] [alias("useOnlyPackageSilentArgs")][switch] $useOnlyPackageSilentArguments = $false, [parameter(Mandatory=$false)][switch]$useOriginalLocation, + [parameter(Mandatory=$false)][scriptblock] $beforeInstall, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) [string]$silentArgs = $silentArgs -join ' ' @@ -405,6 +413,10 @@ param( -GetOriginalFileName } + if ($beforeInstall) { + & $beforeInstall + } + Install-ChocolateyInstallPackage -PackageName $packageName ` -FileType $fileType ` -SilentArgs $silentArgs ` From 3161095222426b9027111e5495240aefbcaec9cc Mon Sep 17 00:00:00 2001 From: FLeXyo Date: Wed, 2 Oct 2019 06:40:21 +0200 Subject: [PATCH 14/17] (#1899) Remove unused variables The example includes two variables, url and url64, which aren't actually being used within the example, and therefore, not required. --- .../helpers/functions/Install-ChocolateyPackage.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 index 030c198de1..2e9cb8db0a 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 @@ -278,8 +278,6 @@ Install-ChocolateyPackage @packageArgs > $packageName= 'bob' $toolsDir = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)" -$url = 'https://somewhere.com/file.msi' -$url64 = 'https://somewhere.com/file-x64.msi' $urlTransform = 'https://somewhere.com/file.mst' $mstFileLocation = Join-Path $toolsDir 'transform.mst' From 1bf9febf50d176fa76027f12ce5aded468ce747f Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Sat, 20 Jul 2019 19:10:12 +0800 Subject: [PATCH 15/17] (maint) Repalce RawGit with raw.githack.com CDN RawGit is shutting down since October 2018, the content already been serving will continue to be served until at least October of 2019, but new content will not be served, the homepage https://rawgit.com/ says: > If you're currently using RawGit, > please stop using it as soon as you can. raw.githack.com is another popular CDN service for repositories on GitHub, and more, also including GitLab and Bitbucket, which provides package maintainers more flexibility. --- CHANGELOG.md | 2 +- README.md | 2 +- src/chocolatey/infrastructure.app/templates/NuspecTemplate.cs | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d8c4c7202..a9fb907c5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -552,7 +552,7 @@ You can also disable the feature `allowEmptyChecksumsSecure` to enforce checksum ## [0.9.10](https://github.com/chocolatey/choco/issues?q=milestone%3A0.9.10+is%3Aclosed) (June 17, 2016) -![Chocolatey Logo](https://cdn.rawgit.com/chocolatey/choco/14a627932c78c8baaba6bef5f749ebfa1957d28d/docs/logo/chocolateyicon.gif "Chocolatey") +![Chocolatey Logo](https://rawcdn.githack.com/chocolatey/choco/14a627932c78c8baaba6bef5f749ebfa1957d28d/docs/logo/chocolateyicon.gif "Chocolatey") The "I got 99 problems, but a package manager ain't one" release. With the release of 0.9.10 (or if you prefer 0.9.10.0), we're about to make everything 100% better in your Windows package management world. We've addressed over 100 features and bugs in this release. We looked at how we could improve PowerShell and we've come out with a [competely internal host](https://github.com/chocolatey/choco/issues/8) that can Prompt and Read-Host in a way that times out and selects default values after a period of time. Speaking of PowerShell, how about some tab completion `choco <tab>` to `choco install node<tab>`? How about never having to [close and reopen your shell again](https://github.com/chocolatey/choco/issues/664)? diff --git a/README.md b/README.md index bc548d603e..b409125836 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Chocolatey - like yum or apt-get, but for Windows You can just call me choco. -![Chocolatey Logo](https://cdn.rawgit.com/chocolatey/choco/14a627932c78c8baaba6bef5f749ebfa1957d28d/docs/logo/chocolateyicon.gif "Chocolatey") +![Chocolatey Logo](https://rawcdn.githack.com/chocolatey/choco/14a627932c78c8baaba6bef5f749ebfa1957d28d/docs/logo/chocolateyicon.gif "Chocolatey") [![](https://img.shields.io/chocolatey/dt/chocolatey.svg)](https://community.chocolatey.org/packages/chocolatey) [![](https://img.shields.io/chocolatey/v/chocolatey.svg)](https://community.chocolatey.org/packages/chocolatey) [![Project Stats](https://www.openhub.net/p/chocolatey/widgets/project_thin_badge.gif)](https://www.openhub.net/p/chocolatey) diff --git a/src/chocolatey/infrastructure.app/templates/NuspecTemplate.cs b/src/chocolatey/infrastructure.app/templates/NuspecTemplate.cs index bc6637fa65..1855eb60cf 100644 --- a/src/chocolatey/infrastructure.app/templates/NuspecTemplate.cs +++ b/src/chocolatey/infrastructure.app/templates/NuspecTemplate.cs @@ -59,7 +59,9 @@ public class NuspecTemplate __REPLACE_AUTHORS_OF_SOFTWARE_COMMA_SEPARATED__ https://_Software_Location_REMOVE_OR_FILL_OUT_ - + + +