Skip to content

Instantly share code, notes, and snippets.

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 ComFreek/87bc3af278c991f729c5135446278ac5 to your computer and use it in GitHub Desktop.
Save ComFreek/87bc3af278c991f729c5135446278ac5 to your computer and use it in GitHub Desktop.
Chocolatey: Fixing "Already referencing a newer version of 'packagename'"
# Improved script of https://github.com/chocolatey/choco/wiki/Troubleshooting#already-referencing-a-newer-version-of-packagename
# This script automatically filters the suspected candidates which are to be removed.
Get-ChildItem -Path "$env:ChocolateyInstall\lib" -Recurse -Filter "*.nupkg" | Where-Object {
# Filter packages with version number
$_.Name -match "^.*\.(\d+|\.){2,}\.nupkg"
} | Where-Object {
# whose parent directory does not contain the same version number
$_.Directory.BaseName -ne $_.BaseName
} | % {
# Remove -WhatIf after having run this script and having double-checked (!) each file listed in the previous
# run if it is really supposed to be removed (check the wiki link for information).
Remove-Item $_.FullName -WhatIf
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment