Check winget version and require update if necessary (#1087)

Added a check for the winget version to ensure it meets the minimum required version.
If the winget version is outdated, the script now exits with an appropriate error message.

Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com>
This commit is contained in:
Omar Hamad 2023-07-11 22:55:33 +03:00 committed by GitHub
parent 7cd00dab49
commit 456a642a1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -162,7 +162,13 @@ https://learn.microsoft.com/windows/package-manager/winget/
'@
}
# TODO: Check system winget version is greater or equal to v1.4.10052
# Check system winget version is greater or equal to v1.4.10052
$wingetVersion = [Version]((winget --version) -replace '.*?(\d+)\.(\d+)\.(\d+).*', '$1.$2.$3')
$requiredVersion = [Version]'1.4.10052'
if ($wingetVersion.CompareTo($requiredVersion) -lt 0) {
$errorMessage = "You need to update your winget to version $requiredVersion or higher."
Exit-WithError $errorMessage
}
# Check connectivity to GitHub
$ProgressPreference = 'SilentlyContinue'