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 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.resources/helpers/chocolateyInstaller.psm1 b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 index 71ce959713..c915808b71 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 # @@ -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,18 @@ 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) { 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: '$_'" 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, diff --git a/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 b/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 index 5bcb20c6cc..353172d2c7 100644 --- a/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 @@ -179,15 +179,15 @@ param( if ($options.Headers.Count -gt 0) { Write-Debug "Setting custom headers" - foreach ($item in $options.Headers.GetEnumerator()) { - $uri = (new-object system.uri $url) - Write-Debug($item.Key + ':' + $item.Value) - switch ($item.Key) { - 'Accept' {$req.Accept = $item.Value} - 'Cookie' {$req.CookieContainer.SetCookies($uri, $item.Value)} - 'Referer' {$req.Referer = $item.Value} - 'User-Agent' {$req.UserAgent = $item.Value} - Default {$req.Headers.Add($item.Key, $item.Value)} + foreach ($key in $options.headers.keys) { + $uri = (New-Object -Typename system.uri $url) + switch ($key) { + 'Accept' {$req.Accept = $options.headers.$key} + 'Cookie' {$req.CookieContainer.SetCookies($uri, $options.headers.$key)} + 'Referer' {$req.Referer = $options.headers.$key} + 'User-Agent' {$req.UserAgent = $options.headers.$key} + 'Authorization' {$re.Authorization = $options.headers.$key} + Default {$req.Headers.Add($key, $options.headers.$key)} } } } @@ -209,7 +209,7 @@ param( if ($headers.ContainsKey("Content-Type")) { $contentType = $headers['Content-Type'] - if ($contentType -ne $null) { + if ($null -ne $contentType) { if ($contentType.ToLower().Contains("text/html") -or $contentType.ToLower().Contains("text/plain")) { Write-Warning "$fileName is of content type $contentType" Set-Content -Path $binaryIsTextCheckFile -Value "$fileName has content type $contentType" -Encoding UTF8 -Force @@ -315,7 +315,7 @@ param( } } } catch { - if ($req -ne $null) { + if ($null -ne $req) { $req.ServicePoint.MaxIdleTime = 0 $req.Abort(); # ruthlessly remove $req to ensure it isn't reused @@ -331,7 +331,7 @@ param( throw "The remote file either doesn't exist, is unauthorized, or is forbidden for url '$url'. $($_.Exception.Message)" } } finally { - if ($res -ne $null) { + if ($null -ne $res) { $res.Close() } diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 index 9131d0f2b3..2e9cb8db0a 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' @@ -271,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' @@ -359,6 +364,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 +411,10 @@ param( -GetOriginalFileName } + if ($beforeInstall) { + & $beforeInstall + } + Install-ChocolateyInstallPackage -PackageName $packageName ` -FileType $fileType ` -SilentArgs $silentArgs ` 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/commands/ChocolateyInstallCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs index aba2c220f2..86162e15c4 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs @@ -27,7 +27,7 @@ namespace chocolatey.infrastructure.app.commands using logging; using services; - [CommandFor("install", "installs packages from various sources")] + [CommandFor("install", "installs packages using configured sources")] public class ChocolateyInstallCommand : ICommand { private readonly IChocolateyPackageService _packageService; diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyNewCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyNewCommand.cs index 6c5ddb194f..cb73152ced 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyNewCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyNewCommand.cs @@ -27,7 +27,7 @@ namespace chocolatey.infrastructure.app.commands using services; using templates; - [CommandFor("new", "generates files necessary for a chocolatey package from a template")] + [CommandFor("new", "creates template files for creating a new Chocolatey package")] public class ChocolateyNewCommand : ICommand { private readonly ITemplateService _templateService; diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs index 89e0b688a9..d58b50442d 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs @@ -24,7 +24,7 @@ namespace chocolatey.infrastructure.app.commands using logging; using services; - [CommandFor("outdated", "retrieves packages that are outdated. Similar to upgrade all --noop")] + [CommandFor("outdated", "retrieves information about packages that are outdated. Similar to upgrade all --noop")] public class ChocolateyOutdatedCommand : ICommand { private readonly IChocolateyPackageService _packageService; diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyPackCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyPackCommand.cs index b3cef3f13b..300d9dac33 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyPackCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyPackCommand.cs @@ -26,7 +26,7 @@ namespace chocolatey.infrastructure.app.commands using logging; using services; - [CommandFor("pack", "packages up a nuspec to a compiled nupkg")] + [CommandFor("pack", "packages nuspec, scripts, and other Chocolatey package resources into a nupkg file")] public class ChocolateyPackCommand : ICommand { private readonly IChocolateyPackageService _packageService; diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyPushCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyPushCommand.cs index 6ec0e0e0dd..9ce1fe6f42 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyPushCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyPushCommand.cs @@ -25,7 +25,7 @@ namespace chocolatey.infrastructure.app.commands using logging; using services; - [CommandFor("push", "pushes a compiled nupkg")] + [CommandFor("push", "pushes a compiled nupkg to a source")] public class ChocolateyPushCommand : ICommand { private readonly IChocolateyPackageService _packageService; diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUnpackSelfCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUnpackSelfCommand.cs index 2917a836d1..fd548dd5af 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUnpackSelfCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUnpackSelfCommand.cs @@ -31,7 +31,7 @@ namespace chocolatey.infrastructure.app.commands using resources; #endif - [CommandFor("unpackself", "have chocolatey set itself up")] + [CommandFor("unpackself", "re-installs Chocolatey base files")] public class ChocolateyUnpackSelfCommand : ICommand { private readonly IFileSystem _fileSystem; 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."); } 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() diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 0b4295d93d..f40e9735ee 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. @@ -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) { @@ -338,7 +336,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 +431,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 +464,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 +566,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 +695,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 +759,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 +873,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 +1004,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 +1206,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 +1231,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)); } } 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 +} 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); 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)); 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 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_ - + + +