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

implement semver comparison for winget version detection #816

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

a-mnich
Copy link
Contributor

@a-mnich a-mnich commented Jan 25, 2025

Proposed Changes

SemVer version comparison

Switch to actual SemVer version comparison for the available / installed version detection.
WinGet distributes "-preview" versions for participants of the insider program which currently isn't supported by the version comparison. This causes WAU to fully download and install an older WinGet version on every run even though the preview version is actually newer.

$WinGetAvailableVersion = "1.9.25200"
$WinGetInstalledVersion = "1.10.40-preview"

$WinGetAvailableVersion -gt $WinGetInstalledVersion
-> True (wrong)

Compare-SemVer -Version1 $WinGetAvailableVersion -Version2 $WinGetInstalledVersion
-> -1 (available is lower then the currently installed version)

$WinGetAvailableVersion = "1.10.40"
$WinGetInstalledVersion = "1.10.40-preview"
Compare-SemVer -Version1 $WinGetAvailableVersion -Version2 $WinGetInstalledVersion
-> 1 (available is greater then the currently installed version -> correct)

$WinGetAvailableVersion = "1.9.25200"
$WinGetInstalledVersion = "1.8.0"
Compare-SemVer -Version1 $WinGetAvailableVersion -Version2 $WinGetInstalledVersion
-> 1 (available is greater then the currently installed version -> correct)

$WinGetAvailableVersion = "1.9.25200"
$WinGetInstalledVersion = "1.9.25200"
Compare-SemVer -Version1 $WinGetAvailableVersion -Version2 $WinGetInstalledVersion
-> 0 (available is equal to the currently installed version -> correct)

replace Replace with TrimStart

v1.10.40-preview was currently detected as 1.10.40-preiew due to Replace("v", "").
TrimStart("v") fixes this.

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

Successfully merging this pull request may close these issues.

1 participant