Skip to content

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

@Miles-Davies-HORIBA

Description

@Miles-Davies-HORIBA

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

Metadata

Metadata

Assignees

Labels

status: staleNo activity, candidate for closing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions