Closed vanceitc closed 1 year ago
Please see the upgrade guide for information on version normalization.
This is a breaking change for us, can you recommend a safe and reliable way to compare versions for equality?
Trying an equality comparison using the [System.Version] type fails.
PS> ([version]"22.1" -eq [version]"22.1.0") False
All versions need a three part version number: ([version]"22.1.0" -eq [version]"22.1.0")
. But without knowing what the use case is, I can't recommend anything. For example, this might be a PowerShell script where you can update the version number string, or it might be something else where you can't.
Tow things I'd suggest:
choco support
to see your options.If you can wait for 2., I'd do 1. first, and work with the Support Team. If you can't wait, downgrade but still reach out to the Support Team.
Fortunately we caught this issue while still trialing C4B, now we will be looking for alternative solutions for now.
Checklist
What You Are Seeing?
After upgrading chocolatey to version 2.0, the internalization process now mangles the package version by adding or trimming zeros from the version number of the output package. This issue complicates automated processes that need to compare the versions.
For example, after internalizing with;
choco.exe download "dotnet4.6.1" --version="4.6.01055.20170308" --source="https://community.chocolatey.org/api/v2/" --output-directory="C:\temp" --internalize
Package 'dotnet4.6.1' with version '4.6.01055.20170308' becomes '4.6.1055.20170308', stripping the leading 0 from patch segment.
Package '7zip.install' with version '22.1' becomes '22.1.0', adding a .0 to the patch segment.
String comparison is obviously going to break, but even converting to the dotnet version type and comparing fails;
PS> ([version]"22.1" -eq [version]"22.1.0") False
Downgrading back to version 1.4 resolves this issue.
What is Expected?
Package version string should be identical after internalization.
How Did You Get This To Happen?
PS> choco.exe download "dotnet4.6.1" --version="4.6.01055.20170308" --source="https://community.chocolatey.org/api/v2/" --output-directory="C:\temp" --internalize
Package 'dotnet4.6.1' with version '4.6.01055.20170308' becomes '4.6.1055.20170308', trimming the leading 0 from patch segment.
Package '7zip.install' with version '22.1' becomes '22.1.0', adding a .0 patch segment.
System Details
Installed Packages
Output Log
Additional Context
No response