Choco: AutoUninstaller - opt-out from packages

Created on 19 Apr 2017  路  13Comments  路  Source: chocolatey/choco

Commit Notes: Add a .skipAutoUninstall and Chocolatey v0.10.8+ will automatically opt out of calling the Auto Uninstaller.

Original Comments

Currently, the AutoUninstaller always runs, regardless of whether the package contains chocolateyUninstall.ps1 or not. For many packages this is harmless. There are some packages, however, where the AutoUninstaller may break other applications. This will happen if a native installer installed a shared component, which is still needed even after uninstalling the package which originally installed it.

Here is a concrete example.

Each of the Visual Studio 2017 product packages (visualstudio2017professional, visualstudio2017buildtools and other visualstudio2017xyz packages) downloads and executes the Visual Studio setup bootstrapper, which performs the following actions:

  • if the Visual Studio Installer application is not present on the system, install it,
  • invoke the Visual Studio Installer to install the specific Visual Studio product.

Therefore, the first installed Visual Studio product will install the Visual Studio Installer and all subsequent VS products will add themselves to the existing VS Installer instance.

Uninstalling the VS Installer removes all VS 2017 products installed on the machine. Because of that, the chocolateyUninstall.ps1 scripts of VS 2017 product packages only invoke the VS Installer, telling it to uninstall the specific VS product. Uninstallation of the VS Installer is handled by a separate package, visualstudio2017-installer, which is a dependency of all VS 2017 product packages.

There is no documented way of installing just the VS Installer itself, so visualstudio2017-installer cannot do it and the Installer gets installed by the first installed VS 2017 product package. The Installer appears in Programs and Features and Chocolatey records that fact for the VS product package. Now, when the product package is uninstalled, its uninstall script leaves the VS Installer intact (because other VS product packages may require it), but the AutoUninstaller "helpfully" proceeds to uninstall it, removing all other VS products present on the machine. (This is slightly mitigated by the fact that Chocolatey does not recognize the uninstaller type and asks the user for permission to proceed, but most users will probably agree.)

I see two solutions:
1) skip running the AutoUninstaller if the package contains chocolateyUninstall.ps1,
2) provide a way for packages to tell Chocolatey to skip running the AutoUninstaller (either as package metadata extension or, preferably, a new helper/.NET API callable from chocolateyUninstall.ps1).

3 - Done Enhancement Up For Grabs

Most helpful comment

This may eventually find its way into the nuspec, but for now, just drop a .skipAutoUninstall file somewhere in the package for 0.10.8+.

All 13 comments

I see two solutions:

  1. skip running the AutoUninstaller if the package contains chocolateyUninstall.ps1,

That may break existing workflows that use the uninstall script to do other things (like remove/cleanup files) and rely on autouninstaller to remove the application. So option 1 is out.

  1. provide a way for packages to tell Chocolatey to skip running the AutoUninstaller (either as package metadata extension or, preferably, a new helper/.NET API callable from chocolateyUninstall.ps1).

This is likely the only way to handle this.

Given there has been discussion on this before, I'm a bit surprised this doesn't already exist as an issue.

I'm trying to package MATLAB and it seems to, even with the installer, leave itself partially installed. However, this isn't a problem (except for maybe it would be nice to have it removed from Programs and Features), so I agree that a package should be able to not run the autouninstaller if it has special cases

This may eventually find its way into the nuspec, but for now, just drop a .skipAutoUninstall file somewhere in the package for 0.10.8+.

image

This seems useful especially as a tweak when you know the autouninstall won't find anything, i.e. all portable packages.

Recommended location? Tools?

@bcurran3 - for portables, it would be superfluous as portables never even run through this autouninstaller code.

So you're saying that if an installer didn't run and the registry didn't get changed, the autouninstaller doesn't try to run? i.e. "Skipping auto uninstaller - No registry snapshot." - got it.

Just as a side note to someone passing by. This file (.skipAutoUninstall) has to be in the tools directory to works properly.

Additions for searchability: ".skipAutoUninstall", ".skipAutoUninstaller", ".skip", "autoUninstaller", "skip auto uninstall"

Just as a side note to someone passing by. This file (.skipAutoUninstall) has to be in the tools directory to works properly.

@wget not in the tools directory, you just have to make sure that the nuspec "files" element accounts for the file. The tools directory is the default in the files element for the nuspec, so that's why it appears so.

@ferventcoder Thanks for the clarification ;)

Was this page helpful?
0 / 5 - 0 ratings