-
Notifications
You must be signed in to change notification settings - Fork 931
Description
Imagine you're not relying on an MSI; you're just bin-deploying to a default (overridable) location and adding an entry to %path% for the machine (overridable to 'user' or 'none').
$ErrorActionPreference = 'Stop'
$pp = Get-PackageParameters
$pathType =
if ('None', 'User', 'Machine' -contains $pp.PathType) { $pp.PathType }
elseif (!$pp.PathType) { 'Machine' }
else { throw "Unrecognized PathType '$($pp.PathType)'" }
$installDir = if ($pp.InstallDir) { $pp.InstallDir } else { "$Env:ProgramFiles\Elevate" }
$toolsPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
$platform = if (Get-OSArchitectureWidth 64) { 'x64' } else { 'x86' }
New-Item $installDir -ItemType Directory -Force | Out-Null
Get-ChildItem "$toolsPath/$platform" |
Move-Item -Destination $installDir -Force
Remove-Item "$toolsPath/*" -Recurse -Exclude *.ps1
if ($pathType -ne 'None') { Install-ChocolateyPath $installDir -PathType $pathType }(Even if this utility worked when shimmed, there's still the question of the configurable installation location.)
When the user types choco uninstall thepackage, how should chocolateyUninstall.ps1 find the correct installation folder to delete and the correct path variable (machine/user/none) to modify?
I would have expected Get-PackageParameters to be persisted by Chocolatey and provided to the uninstall script. It makes sense to allow them to be individually overridden by passing --params to choco uninstall, but it doesn't make sense for them to start null and thus require the user to duplicate the exact parameters used previously if the user wants a successful uninstall. That's not very user-friendly.
Also, I don't want to have to author an MSI just to have a decently reliable package uninstaller. (I notice that the only other package I can find that allows a user/machine switch only uninstalls the machine path.)
Is there a reason we can't make this just start working out of the box? I'd expect this to apply to uninstalls for sure; probably upgrades as well. Seems like the obvious place to store the --params string is the same place that keeps a record that the package is installed.