diff --git a/.uppercut b/.uppercut index 3bfb6e79cd..7a65d21225 100644 --- a/.uppercut +++ b/.uppercut @@ -17,7 +17,7 @@ - + diff --git a/CHANGELOG.md b/CHANGELOG.md index 655f82d1c3..ceaa22db78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,32 @@ This covers changes for the "chocolatey" and "chocolatey.lib" packages, which ar **NOTE**: If you have a licensed edition of Chocolatey ("chocolatey.extension"), refer to this in tandem with [Chocolatey Licensed CHANGELOG](https://github.com/chocolatey/choco/blob/master/CHANGELOG_LICENSED.md). +## [0.10.2](https://github.com/chocolatey/choco/issues?q=milestone%3A0.10.2+is%3Aclosed) (September 30, 2016) + +We're dubbing this the "Every Joe" release in honor of a friend that just lost his fight with brain cancer. If you want to help further research, please make a donation to a cancer research association of your choosing (e.g. the [American Brain Tumor Assocation](http://www.abta.org/thank-you.html)). + +A couple of important fixes/enhancements in this release. Most of the improvements are about providing better feedback to you and fixing minor issues. The big one surrounds when packages set a download path for a file using `$env:TEMP`, choco will ensure that the file can still be found for later use. + +### BUG FIXES + +* Fix - Downloaded file is at old `$env:TEMP\chocolatey\chocolatey` location, but install calls with just `$env:TEMP\chocolatey\` location - see [#969](https://github.com/chocolatey/choco/issues/969) +* Fix - [Pro/Business] UseOriginalLocation fails when there is no 64bit file - see [#972](https://github.com/chocolatey/choco/issues/972) +* Fix - Do not use unparsed options as package names - see [#983](https://github.com/chocolatey/choco/issues/983) + +### IMPROVEMENTS + +* Start-ChocolateyProcessAsAdmin enhancements - see [#977](https://github.com/chocolatey/choco/issues/977) +* Log PowerShell function calls better - see [#976](https://github.com/chocolatey/choco/issues/976) +* Allow environment variables in some config settings - see [#971](https://github.com/chocolatey/choco/issues/971) +* [Pro/Business] Provide license type to environment variables - see [#968](https://github.com/chocolatey/choco/issues/968) +* Note that chocolateyUninstall.ps1 may no longer required in template - see [#982](https://github.com/chocolatey/choco/issues/982) +* Provide guidance when licensed only options are passed to FOSS - see [#984](https://github.com/chocolatey/choco/issues/984) +* Rollback automatically when a user cancels an operation - see [#985](https://github.com/chocolatey/choco/issues/985) +* Explain how to workaround a failing uninstall - see [#573](https://github.com/chocolatey/choco/issues/573) +* Remove extra forward slashes in url - see [#986](https://github.com/chocolatey/choco/issues/986) +* Side by side uninstall enhancements - see [#992](https://github.com/chocolatey/choco/issues/992) + + ## [0.10.1](https://github.com/chocolatey/choco/issues?q=milestone%3A0.10.1+is%3Aclosed) (September 19, 2016) We're dubbing this the "Shhh! Keep that secret please" release. We've found that when passing in passwords and other sensitive arguments, those items can end up in the logs in clear text. We've addressed this in [#948](https://github.com/chocolatey/choco/issues/948) and [#953](https://github.com/chocolatey/choco/issues/953). When it comes to passing sensitive arguments through to native installers, you can set up environment variables with those sensitive args and pass those arguments directly through to `Start-ChocolateyProcessAsAdmin`. If you prefer a better experience, the licensed version allows passing sensitive options directly through choco.exe as `--install-arguments-sensitive` and `--package-parameters-sensitive`. Read more in the [Licensed CHANGELOG](https://github.com/chocolatey/choco/blob/master/CHANGELOG_LICENSED.md). diff --git a/docs/logo/LogoUsePolicy.md b/docs/logo/LogoUsePolicy.md index db46cbf62d..03d4e298de 100644 --- a/docs/logo/LogoUsePolicy.md +++ b/docs/logo/LogoUsePolicy.md @@ -2,14 +2,16 @@ The Apache 2.0 license does not apply for the logos/marks. Chocolatey open source code falls under the Apache 2.0 license, which permits third parties to copy and redistribute the underlying software under the terms of the license. However, the Apache 2.0 license does not provide any license or right to use any of the Chocolatey marks, including logos. You may redistribute the applicable Chocolatey open source software under the terms of the Apache 2.0 license, but you may not use the Chocolatey marks in doing so without express written permission from RealDimensions Software, LLC. +# Chocolatey Marks / Logo + You must obtain written permission from RealDimensions Software, LLC, to use the Chocolatey marks for any use, including but not limited to; (i) merchandising purposes (e.g. T-shirts, mugs); (ii) on or in relation to a software product that includes or is built on top of any Chocolatey product, including Chocolatey's open source projects; or (iii) in an attention-getting or branding manner. Without the express prior written consent of RealDimensions Software, LLC, no Chocolatey Marks may be used in a manner that implies an affiliation with, approval by, endorsement of or sponsorship by RealDimensions Software, LLC. -### General Use +## General Use You may use Chocolatey marks/logos, without a license, provided such use complies with the following requirements: (i) the Chocolatey mark is used only to refer to the Chocolatey project, framework, and/or technology; (ii) the Chocolatey mark is not used as part of your product, brand, domain, URL, or service name; (iii) the Chocolatey mark appears less prominent than your company or product name; (iv) the reference to Chocolatey does not create a sense of endorsement, sponsorship, or ownership by Chocolatey and/or RealDimensions Software, LLC; and/or (v) your use of the Chocolatey mark is necessary to fully describe your services or products and is limited to as much of the Chocolatey Mark as is necessary for such identification ("Nominative Use"). NO OTHER USE OF THE CHOCOLATEY MARK IS PERMITTED WITHOUT A WRITTEN LICENSE AGREEMENT. -### Plain Speak +## Plain Speak **NOTE**: This section ("Plain Speak") in no way changes what is written in the rest of this document. This only attempts to provide some clarity. If there is a conflict with another section, the other section applies. -Without an express written agreement, you cannot use the Chocolatey logos as part of your brand/product. \ No newline at end of file +Without an express written agreement, you cannot use the Chocolatey logos as part of your brand/product. diff --git a/nuget/chocolatey/chocolatey.nuspec b/nuget/chocolatey/chocolatey.nuspec index f0ab885fac..27fe621d1c 100644 --- a/nuget/chocolatey/chocolatey.nuspec +++ b/nuget/chocolatey/chocolatey.nuspec @@ -55,6 +55,32 @@ In that mess there is a link to the [PowerShell Chocolatey module reference](htt See all - https://github.com/chocolatey/choco/blob/stable/CHANGELOG.md +## 0.10.2 + +We're dubbing this the "Every Joe" release in honor of a friend that just lost his fight with brain cancer. If you want to help further research, please make a donation to a cancer research association of your choosing (e.g. the [American Brain Tumor Assocation](http://www.abta.org/thank-you.html)). + +A couple of important fixes/enhancements in this release. Most of the improvements are about providing better feedback to you and fixing minor issues. The big one surrounds when packages set a download path for a file using `$env:TEMP`, choco will ensure that the file can still be found for later use. + +### BUG FIXES + +* Fix - Downloaded file is at old `$env:TEMP\chocolatey\chocolatey` location, but install calls with just `$env:TEMP\chocolatey\` location - see [#969](https://github.com/chocolatey/choco/issues/969) +* Fix - [Pro/Business] UseOriginalLocation fails when there is no 64bit file - see [#972](https://github.com/chocolatey/choco/issues/972) +* Fix - Do not use unparsed options as package names - see [#983](https://github.com/chocolatey/choco/issues/983) + +### IMPROVEMENTS + +* Start-ChocolateyProcessAsAdmin enhancements - see [#977](https://github.com/chocolatey/choco/issues/977) +* Log PowerShell function calls better - see [#976](https://github.com/chocolatey/choco/issues/976) +* Allow environment variables in some config settings - see [#971](https://github.com/chocolatey/choco/issues/971) +* [Pro/Business] Provide license type to environment variables - see [#968](https://github.com/chocolatey/choco/issues/968) +* Note that chocolateyUninstall.ps1 may no longer required in template - see [#982](https://github.com/chocolatey/choco/issues/982) +* Provide guidance when licensed only options are passed to FOSS - see [#984](https://github.com/chocolatey/choco/issues/984) +* Rollback automatically when a user cancels an operation - see [#985](https://github.com/chocolatey/choco/issues/985) +* Explain how to workaround a failing uninstall - see [#573](https://github.com/chocolatey/choco/issues/573) +* Remove extra forward slashes in url - see [#986](https://github.com/chocolatey/choco/issues/986) +* Side by side uninstall enhancements - see [#992](https://github.com/chocolatey/choco/issues/992) + + ## 0.10.1 We're dubbing this the "Shhh! Keep that secret please" release. We've found that when passing in passwords and other sensitive arguments, those items can end up in the logs in clear text. We've addressed this in [#948](https://github.com/chocolatey/choco/issues/948) and [#953](https://github.com/chocolatey/choco/issues/953). When it comes to passing sensitive arguments through to native installers, you can set up environment variables with those sensitive args and pass those arguments directly through to `Start-ChocolateyProcessAsAdmin`. If you prefer a better experience, the licensed version allows passing sensitive options directly through choco.exe as `--install-arguments-sensitive` and `--package-parameters-sensitive`. Read more in the [Licensed CHANGELOG](https://github.com/chocolatey/choco/blob/master/CHANGELOG_LICENSED.md). diff --git a/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 b/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 index 90f893220c..d446fe6540 100644 --- a/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 @@ -203,6 +203,9 @@ param( Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters + if ($url -ne $null) { $url = $url.Replace("//","/").Replace(":/","://") } + if ($url64bit -ne $null) { $url64bit = $url64bit.Replace("//","/").Replace(":/","://") } + $url32bit = $url # allow user provided values for checksumming diff --git a/src/chocolatey.resources/redirects/RefreshEnv.cmd b/src/chocolatey.resources/redirects/RefreshEnv.cmd index a69184c2e0..3f11f901b2 100644 --- a/src/chocolatey.resources/redirects/RefreshEnv.cmd +++ b/src/chocolatey.resources/redirects/RefreshEnv.cmd @@ -8,7 +8,8 @@ :: With this batch file, there should be no need to reload command :: environment every time you want environment changes to propagate -echo | set /p dummy="Reading environment variables from registry. Please wait... " +::echo "RefreshEnv.cmd only works from cmd.exe, please install the Chocolatey Profile to take advantage of refreshenv from PowerShell" +echo | set /p dummy="Refreshing environment variables from registry for cmd.exe. Please wait... " goto main diff --git a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs index 78f329f416..96324f2cfe 100644 --- a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs @@ -80,6 +80,9 @@ public override void Context() fileSystem.Setup(f => f.directory_exists(registryKeys.FirstOrDefault().InstallLocation)).Returns(true); registryService.Setup(r => r.installer_value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(true); fileSystem.Setup(f => f.get_full_path(expectedUninstallString)).Returns(expectedUninstallString); + + var field = typeof(ApplicationParameters).GetField("AllowPrompts"); + field.SetValue(null, false); } } diff --git a/src/chocolatey/infrastructure.app/ApplicationParameters.cs b/src/chocolatey/infrastructure.app/ApplicationParameters.cs index 4c343f808e..7e0fee610b 100644 --- a/src/chocolatey/infrastructure.app/ApplicationParameters.cs +++ b/src/chocolatey/infrastructure.app/ApplicationParameters.cs @@ -109,10 +109,18 @@ public static class Environment public static readonly string HashProviderFileTooBig = "UnableToDetectChanges_FileTooBig"; public static readonly string HashProviderFileLocked = "UnableToDetectChanges_FileLocked"; - + + /// + /// This is a readonly bool set to true. It is only shifted for specs. + /// public static readonly bool LockTransactionalInstallFiles = true; public static readonly string PackagePendingFileName = ".chocolateyPending"; + /// + /// This is a readonly bool set to true. It is only shifted for specs. + /// + public static readonly bool AllowPrompts = true; + public static class Tools { //public static readonly string WebPiCmdExe = _fileSystem.combine_paths(InstallLocation, "nuget.exe"); diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs index a8654b5c1f..597cd04ed1 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs @@ -17,6 +17,7 @@ namespace chocolatey.infrastructure.app.commands { using System; using System.Collections.Generic; + using System.Linq; using attributes; using commandline; using configuration; @@ -157,7 +158,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon public virtual void handle_additional_argument_parsing(IList unparsedArguments, ChocolateyConfiguration configuration) { configuration.Input = string.Join(" ", unparsedArguments); - configuration.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator.to_string(), unparsedArguments); + configuration.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator.to_string(), unparsedArguments.Where(arg => !arg.StartsWith("-"))); } public virtual void handle_validation(ChocolateyConfiguration configuration) @@ -177,6 +178,22 @@ public virtual void handle_validation(ChocolateyConfiguration configuration) { throw new ApplicationException("Force dependencies can only be used with force also turned on."); } + + if (!string.IsNullOrWhiteSpace(configuration.Input)) + { + var unparsedOptionsAndPackages = configuration.Input.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); + if (!configuration.Information.IsLicensedVersion) + { + foreach (var argument in unparsedOptionsAndPackages.or_empty_list_if_null()) + { + var arg = argument.to_lower(); + if (arg.StartsWith("-dir") || arg.StartsWith("--dir") || arg.StartsWith("-install") || arg.StartsWith("--install")) + { + throw new ApplicationException("It appears you are attempting to use options that may be only available in licensed versions of Chocolatey ('{0}'). Please remove and consult the documentation.".format_with(arg)); + } + } + } + } } public virtual void help_message(ChocolateyConfiguration configuration) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs index b132ada68f..0417a17cb4 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs @@ -17,6 +17,7 @@ namespace chocolatey.infrastructure.app.commands { using System; using System.Collections.Generic; + using System.Linq; using attributes; using commandline; using configuration; @@ -118,7 +119,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon public virtual void handle_additional_argument_parsing(IList unparsedArguments, ChocolateyConfiguration configuration) { configuration.Input = string.Join(" ", unparsedArguments); - configuration.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator.to_string(), unparsedArguments); + configuration.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator.to_string(), unparsedArguments.Where(arg => !arg.StartsWith("-"))); } public virtual void handle_validation(ChocolateyConfiguration configuration) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs index cf3d9f25e3..dad5245eaa 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs @@ -17,6 +17,7 @@ namespace chocolatey.infrastructure.app.commands { using System; using System.Collections.Generic; + using System.Linq; using attributes; using commandline; using configuration; @@ -162,7 +163,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon public virtual void handle_additional_argument_parsing(IList unparsedArguments, ChocolateyConfiguration configuration) { configuration.Input = string.Join(" ", unparsedArguments); - configuration.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator.to_string(), unparsedArguments); + configuration.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator.to_string(), unparsedArguments.Where(arg => !arg.StartsWith("-"))); } public virtual void handle_validation(ChocolateyConfiguration configuration) @@ -171,6 +172,28 @@ public virtual void handle_validation(ChocolateyConfiguration configuration) { throw new ApplicationException("Package name is required. Please pass at least one package name to upgrade."); } + + if (configuration.ForceDependencies && !configuration.Force) + { + throw new ApplicationException("Force dependencies can only be used with force also turned on."); + } + + if (!string.IsNullOrWhiteSpace(configuration.Input)) + { + var unparsedOptionsAndPackages = configuration.Input.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); + if (!configuration.Information.IsLicensedVersion) + { + foreach (var argument in unparsedOptionsAndPackages.or_empty_list_if_null()) + { + var arg = argument.to_lower(); + if (arg.StartsWith("-dir") || arg.StartsWith("--dir") || arg.StartsWith("-install") || arg.StartsWith("--install")) + { + throw new ApplicationException( + "It appears you are attempting to use options that may be only available in licensed versions of Chocolatey ('{0}'). Please remove and consult the documentation.".format_with(arg)); + } + } + } + } } public virtual void help_message(ChocolateyConfiguration configuration) diff --git a/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs b/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs index 0a2d4235c8..acf86aa79f 100644 --- a/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs +++ b/src/chocolatey/infrastructure.app/nuget/ChocolateyPackagePathResolver.cs @@ -34,16 +34,26 @@ public ChocolateyPackagePathResolver(IFileSystem nugetFileSystem, bool useSideBy public override string GetInstallPath(IPackage package) { - return Path.Combine(_nugetFileSystem.Root, GetPackageDirectory(package)); + var packageVersionPath = Path.Combine(_nugetFileSystem.Root, GetPackageDirectory(package.Id,package.Version,useVersionInPath:true)); + if (_nugetFileSystem.DirectoryExists(packageVersionPath)) return packageVersionPath; + + + return Path.Combine(_nugetFileSystem.Root, GetPackageDirectory(package.Id, package.Version)); } public override string GetPackageDirectory(string packageId, SemanticVersion version) + { + return GetPackageDirectory(packageId, version, UseSideBySidePaths); + } + + public string GetPackageDirectory(string packageId, SemanticVersion version, bool useVersionInPath) { string directory = packageId; - if (UseSideBySidePaths) + if (useVersionInPath) { directory += "." + version.to_string(); } + return directory; } diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 7c98ab7257..1db1471f42 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -332,6 +332,9 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu { EnvironmentSettings.reset_environment_variables(config); set_pending(packageResult, config); + + this.Log().Info("{0} package files {1} is complete. Performing other installation steps.".format_with(packageResult.Name, commandName.to_string())); + var pkgInfo = _packageInfoService.get_package_information(packageResult.Package); if (config.AllowMultipleVersions) { @@ -754,6 +757,26 @@ public ConcurrentDictionary uninstall_run(ChocolateyConfi Environment.ExitCode = 1; } + if (uninstallFailures != 0) + { + 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 + 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. + +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. + "); + } + randomly_notify_about_pro_business(config); return packageUninstalls; @@ -1117,7 +1140,17 @@ private void rollback_previous_version(ChocolateyConfiguration config, PackageRe this.Log().Debug("Attempting rollback"); var rollback = true; - if (config.PromptForConfirmation) + var shouldPrompt = config.PromptForConfirmation; + + // if user canceled, then automatically rollback without prompting. + //MSI ERROR_INSTALL_USEREXIT - 1602 - https://support.microsoft.com/en-us/kb/304888 / https://msdn.microsoft.com/en-us/library/aa376931.aspx + //ERROR_INSTALL_CANCEL - 15608 - https://msdn.microsoft.com/en-us/library/windows/desktop/ms681384.aspx + if (Environment.ExitCode == 15608 || Environment.ExitCode == 1602) + { + shouldPrompt = false; + } + + if (shouldPrompt) { var selection = InteractivePrompt.prompt_for_confirmation( " Unsuccessful operation for {0}.{1} Rollback to previous version (package files only)?".format_with(packageResult.Name, Environment.NewLine), diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 86b59f4124..e7d8c3003b 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -814,7 +814,7 @@ public void backup_existing_version(ChocolateyConfiguration config, IPackage ins if (_fileSystem.directory_exists(pkgInstallPath)) { - this.Log().Debug("Backing up existing {0} prior to upgrade.".format_with(installedPackage.Id)); + this.Log().Debug("Backing up existing {0} prior to operation.".format_with(installedPackage.Id)); var backupLocation = pkgInstallPath.Replace(ApplicationParameters.PackagesLocation, ApplicationParameters.PackageBackupLocation); @@ -1011,9 +1011,10 @@ public ConcurrentDictionary uninstall_run(ChocolateyConfi return; } - // is this the latest version or have you passed --sxs? This is the only way you get through to the continue action. + // is this the latest version, have you passed --sxs, or is this a side-by-side install? This is the only way you get through to the continue action. var latestVersion = packageManager.LocalRepository.FindPackage(e.Package.Id); - if (latestVersion.Version == pkg.Version || config.AllowMultipleVersions) + var pkgInfo = _packageInfoService.get_package_information(e.Package); + if (latestVersion.Version == pkg.Version || config.AllowMultipleVersions || (pkgInfo != null && pkgInfo.IsSideBySide)) { packageResult.Messages.Add(new ResultMessage(ResultType.Debug, ApplicationParameters.Messages.ContinueChocolateyAction)); if (continueAction != null) continueAction.Invoke(packageResult); @@ -1173,13 +1174,13 @@ public ConcurrentDictionary uninstall_run(ChocolateyConfi { using (packageManager.SourceRepository.StartOperation( RepositoryOperationNames.Install, - packageName, - version == null ? null : version.ToString())) + packageVersion.Id, packageVersion.Version.to_string()) + ) { ensure_package_files_have_compatible_attributes(config, packageVersion, pkgInfo); rename_legacy_package_version(config, packageVersion, pkgInfo); backup_existing_version(config, packageVersion, pkgInfo); - packageManager.UninstallPackage(packageVersion, forceRemove: config.Force, removeDependencies: config.ForceDependencies); + packageManager.UninstallPackage(packageVersion.Id, forceRemove: config.Force, removeDependencies: config.ForceDependencies, version: packageVersion.Version); ensure_nupkg_is_removed(packageVersion, pkgInfo); remove_installation_files(packageVersion, pkgInfo); remove_cache_for_package(config, packageVersion); diff --git a/src/chocolatey/infrastructure.app/services/PowershellService.cs b/src/chocolatey/infrastructure.app/services/PowershellService.cs index 55de1e2847..966328342e 100644 --- a/src/chocolatey/infrastructure.app/services/PowershellService.cs +++ b/src/chocolatey/infrastructure.app/services/PowershellService.cs @@ -234,8 +234,10 @@ public bool run_action(ChocolateyConfiguration configuration, PackageResult pack if (selection.is_equal_to("yes")) shouldRun = true; if (selection.is_equal_to("no")) { - Environment.ExitCode = 1; - packageResult.Messages.Add(new ResultMessage(ResultType.Error, "User cancelled powershell portion of installation for '{0}'.{1} Specify -n to skip automated script actions.".format_with(chocoPowerShellScript, Environment.NewLine))); + //MSI ERROR_INSTALL_USEREXIT - 1602 - https://support.microsoft.com/en-us/kb/304888 / https://msdn.microsoft.com/en-us/library/aa376931.aspx + //ERROR_INSTALL_CANCEL - 15608 - https://msdn.microsoft.com/en-us/library/windows/desktop/ms681384.aspx + Environment.ExitCode = 15608; + packageResult.Messages.Add(new ResultMessage(ResultType.Error, "User canceled powershell portion of installation for '{0}'.{1} Specify -n to skip automated script actions.".format_with(chocoPowerShellScript, Environment.NewLine))); } } diff --git a/src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs b/src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs index bf2fd9d1fc..de23a9aade 100644 --- a/src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs +++ b/src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs @@ -22,6 +22,9 @@ public class ChocolateyUninstallTemplate # $f='c:\path\to\thisFile.ps1' # gc $f | ? {$_ -notmatch ""^\s*#""} | % {$_ -replace '(^.*?)\s*?[^``]#.*','$1'} | Out-File $f+"".~"" -en utf8; mv -fo $f+"".~"" $f +## NOTE: In 80-90% of the cases (95% with licensed versions due to Package Synchronizer and other enhancements), you may +## not need this file due to AutoUninstaller. See https://chocolatey.org/docs/commands-uninstall + ## If this is an MSI, cleaning up comments is all you need. ## If this is an exe, change installerType and silentArgs ## Auto Uninstaller should be able to detect and handle registry uninstalls (if it is turned on, it is in preview for 0.9.9). diff --git a/src/chocolatey/infrastructure/adapters/Console.cs b/src/chocolatey/infrastructure/adapters/Console.cs index 64d92b266c..32b12da974 100644 --- a/src/chocolatey/infrastructure/adapters/Console.cs +++ b/src/chocolatey/infrastructure/adapters/Console.cs @@ -15,8 +15,10 @@ namespace chocolatey.infrastructure.adapters { + using System; using System.IO; using System.Runtime.InteropServices; + using app; using commandline; using platforms; @@ -27,21 +29,29 @@ public sealed class Console : IConsole { public string ReadLine() { + if (!ApplicationParameters.AllowPrompts) return string.Empty; + return System.Console.ReadLine(); } public string ReadLine(int timeoutMilliseconds) { + if (!ApplicationParameters.AllowPrompts) return string.Empty; + return ReadLineTimeout.read(timeoutMilliseconds); } public System.ConsoleKeyInfo ReadKey(bool intercept) { + if (!ApplicationParameters.AllowPrompts) return new System.ConsoleKeyInfo('\0', ConsoleKey.Enter, false, false, false); + return System.Console.ReadKey(intercept); } public System.ConsoleKeyInfo ReadKey(int timeoutMilliseconds) { + if (!ApplicationParameters.AllowPrompts) return new System.ConsoleKeyInfo('\0', ConsoleKey.Enter, false, false, false); + return ReadKeyTimeout.read_key(timeoutMilliseconds); }