Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Chocolatey: Fixing "Already referencing a newer version of 'packagename'"
# Improved script of
# 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