Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoUninstaller - opt-out from packages #1257

Closed
jberezanski opened this issue Apr 19, 2017 · 13 comments
Closed

AutoUninstaller - opt-out from packages #1257

jberezanski opened this issue Apr 19, 2017 · 13 comments

Comments

@jberezanski
Copy link

jberezanski commented Apr 19, 2017

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).
@ferventcoder
Copy link
Member

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.

@ferventcoder
Copy link
Member

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

@ferventcoder ferventcoder modified the milestones: 0.10.7, 0.10.8 Jun 6, 2017
@steelcowboy
Copy link

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

@ferventcoder
Copy link
Member

ferventcoder commented Aug 20, 2017

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+.

@ferventcoder ferventcoder added this to the 0.10.8 milestone Aug 20, 2017
@ferventcoder ferventcoder self-assigned this Aug 20, 2017
@ferventcoder
Copy link
Member

image

@bcurran3
Copy link

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

Recommended location? Tools?

ferventcoder added a commit that referenced this issue Aug 21, 2017
Previously, AutoUninstaller alone made decisions on whether it should
run based on the state of the uninstall script and environmental
information surrounding it. In some cases, packages should have the
ability to opt out of having Automatic Uninstaller from attempting to
remove any files.

Allow a package to contain a `.skipAutoUninstall` file to skip using
Automatic Uninstaller.
ferventcoder added a commit to ferventcoder/choco that referenced this issue Aug 21, 2017
* stable:
  (chocolateyGH-1386) Default Template - Overall help and todo
  (chocolateyGH-1257) AutoUninstaller: package opt-out
  (maint) tab - add pro list options
  (chocolateyGH-1383) Fix - no pkg args cause "value cannot be null"
  (chocolateyGH-1385) Template - do not treat binary as text file
  (maint) typo
  (maint) Do not package pdb w/exe
  (doc) update generated docs
@ferventcoder
Copy link
Member

ferventcoder commented Aug 23, 2017

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

@bcurran3
Copy link

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.

@ferventcoder
Copy link
Member

Basically the above yes. 👍
It's one step past this one -

var packageLocation = packageResult.InstallLocation;
if (!string.IsNullOrWhiteSpace(packageLocation))
{
var skipFiles = _fileSystem.get_files(packageLocation, SKIP_FILE_NAME + "*", SearchOption.AllDirectories).Where(p => !p.to_lower().contains("\\templates\\"));
if (skipFiles.Count() != 0)
{
this.Log().Info(" Skipping auto uninstaller - Package contains a skip file ('{0}').".format_with(SKIP_FILE_NAME));
return;
}
}
var pkgInfo = _packageInfoService.get_package_information(packageResult.Package);
if (pkgInfo.RegistrySnapshot == null)
{
this.Log().Info(" Skipping auto uninstaller - No registry snapshot.");
return;
}
.

@ferventcoder ferventcoder changed the title Packages should be able to opt-out of AutoUninstaller AutoUninstaller - opt out from package Aug 29, 2017
@ferventcoder ferventcoder changed the title AutoUninstaller - opt out from package AutoUninstaller - opt-out from package Aug 29, 2017
@ferventcoder ferventcoder changed the title AutoUninstaller - opt-out from package AutoUninstaller - opt-out from packages Aug 29, 2017
@wget
Copy link

wget commented Jul 10, 2018

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

@ferventcoder
Copy link
Member

ferventcoder commented Aug 23, 2018

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

@ferventcoder
Copy link
Member

ferventcoder commented Sep 19, 2020

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.

@wget
Copy link

wget commented Oct 20, 2020

@ferventcoder Thanks for the clarification ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants