Skip to content

Instantly share code, notes, and snippets.

@mwallner
Created October 25, 2017 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwallner/b10bcd6ccd1f7b3d65a56a06c8c8aa0a to your computer and use it in GitHub Desktop.
Save mwallner/b10bcd6ccd1f7b3d65a56a06c8c8aa0a to your computer and use it in GitHub Desktop.
choco foo/bar force-uninstall dependency
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>bar</id>
<version>1.0.0</version>
<title>bar (Install)</title>
<authors>me</authors>
<tags>bar</tags>
<summary>this is bar</summary>
<description>this is bar </description>
</metadata>
</package>
# you'll need to put some file into bar (cannot create a package without dependencies and content)
echo "this is bar"
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>foo</id>
<version>1.0.0</version>
<title>foo (Install)</title>
<authors>me</authors>
<tags>foo</tags>
<summary>this is foo</summary>
<description>this is foo </description>
<dependencies>
<dependency id="bar"/>
</dependencies>
</metadata>
</package>
PS D:\tmp\choco> ls
Verzeichnis: D:\tmp\choco
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 25.10.2017 22:03 bar
d----- 25.10.2017 22:03 foo
-a---- 25.10.2017 22:03 2670 bar.1.0.0.nupkg
-a---- 25.10.2017 22:03 2452 foo.1.0.0.nupkg
PS D:\tmp\choco> cinst foo -s . -y
Chocolatey v0.10.8 Business
Installing the following packages:
foo
By installing you accept licenses for the packages.
bar v1.0.0
bar package files install completed. Performing other installation steps.
this is foo
The install of bar was successful.
Software install location not explicitly set, could be in package or
default install location if installer.
foo v1.0.0
foo package files install completed. Performing other installation steps.
The install of foo was successful.
Software install location not explicitly set, could be in package or
default install location if installer.
Chocolatey installed 2/2 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS D:\tmp\choco> choco uninstall bar
Chocolatey v0.10.8 Business
Uninstalling the following packages:
bar
bar not uninstalled. An error occurred during uninstall:
Unable to uninstall 'bar 1.0.0' because 'foo 1.0.0' depends on it.
Chocolatey uninstalled 0/1 packages. 1 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Failures
- bar (exited 1) - bar not uninstalled. An error occurred during uninstall:
Unable to uninstall 'bar 1.0.0' because 'foo 1.0.0' depends on it.
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.
PS D:\tmp\choco> choco uninstall bar --force
Chocolatey v0.10.8 Business
Uninstalling the following packages:
bar
[NuGet] Uninstalling 'bar 1.0.0' might cause 'foo 1.0.0' to be broken.
bar v1.0.0 (forced)
Skipping auto uninstaller - No registry snapshot.
bar has been successfully uninstalled.
Chocolatey uninstalled 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS D:\tmp\choco> cpack .\foo\foo.nuspec
Chocolatey v0.10.8 Business
Attempting to build package from 'foo.nuspec'.
Successfully created package 'D:\tmp\choco\foo.2.0.0.nupkg'
PS D:\tmp\choco> cup foo -s . -y
Chocolatey v0.10.8 Business
Upgrading the following packages:
foo
By upgrading you accept licenses for the packages.
You have foo v1.0.0 installed. Version 2.0.0 is available based on your source(s).
bar v1.0.0
bar package files upgrade completed. Performing other installation steps.
this is foo
The upgrade of bar was successful.
Software install location not explicitly set, could be in package or
default install location if installer.
foo v2.0.0
foo package files upgrade completed. Performing other installation steps.
The upgrade of foo was successful.
Software install location not explicitly set, could be in package or
default install location if installer.
Chocolatey upgraded 2/2 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment