Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest Version is broken if the version goes > 9 because Version is a 'string' #139

Open
Miles-Davies-HORIBA opened this issue Feb 24, 2023 · 0 comments

Comments

@Miles-Davies-HORIBA
Copy link

We have a module with version 2.10.0 and PSDepend won't upgrade machines to it because they have the 'latest' version.

You have the latest version of [module-name], with installed version [2.8.0] and PSGallery version
[2.10.0]

The issue seems to be the use of the module version, which is a string, in comparisons. Package.ps1 and PSGalleryModule have code similar to

$ExistingVersion = $Existing | Measure-Object -Property Version -Maximum | Select-Object -ExpandProperty Maximum

where the Measure-Object statement is doing an alpha sort not a 'Version' sort because the Version property is a string type not a Version or more correctly a SemanticVersion type.

This can be fixed by using a calculated property caste to a Version or SemanticVersion

$ExistingVersion = $Existing | Select-Object -Property @{ Name = 'Version' ; Expression = { [Version]$_.Version}} | Measure-Object -Property Version -Maximum | Select-Object -ExpandProperty Maximum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant