Closed God-damnit-all closed 1 year ago
Same issue here. I found out that Powershell cannot cast strings like "2.1.0-alpha-20230614" to [System.Version]
, so the if condition fails and the variable $InstalledPackages
is not set to any value (for instance, try to type [System.Version]"2.1.0-alpha-20230614"
and [System.Version]"2.1.0"
in Powershell). However, typecasting is probably unnecessary here because one can simply use [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$env:chocolateyinstall\choco.exe").ProductMajorPart
to retrieve the major version number. This should solve the problem.
@ekoam - Thanks. I've tested and will push an update with that change.
Updated.
choco install choco-cleaner --version=1.1.1
@ekoam - Thanks. I've tested and will push an update with that change.
You kinda ignored my PR. #330
The ProductMajorPart property is definitely a great find, but there are aspects to my PR that would also be a good improvement. But since I didn't get a reply to it, I'm not even sure if it's worth the time incorporating.
Sorry, didn't see it until now.
Using Choco-Cleaner.ps1 v1.1.0 (2023-06-12)
This is first triggered by choco-cleaner not being able to parse the version of choco.exe:
This causes line 423's else block to trigger, which is
$InstalledPackages = & choco list -lo -r -y
and this just causes choco to print out the help section since it no longer recognizes-lo
since 2.0. This makes it end up removing everything in .chocolatey except for packages.config