Skip to content

Commit 7939b9e

Browse files
author
Robin Stolpe
committed
fixed version issue
1 parent 7abf197 commit 7939b9e

6 files changed

Lines changed: 17 additions & 15 deletions

File tree

.src/private/function/Confirm-RSWinGet.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@
5757
[System.Object]$GithubInfoRestData = Invoke-RestMethod -Uri $GitHubUrl -Method Get -Headers $GithubHeaders -TimeoutSec 10 | Select-Object -Property assets, tag_name
5858
}
5959

60-
[string]$latestVersion = $GithubInfoRestData.tag_name.Substring(1)
61-
6260
[System.Object]$GitHubInfo = [PSCustomObject]@{
63-
Tag = $latestVersion
61+
Tag = $($GithubInfoRestData.tag_name.Substring(1))
6462
DownloadUrl = $GithubInfoRestData.assets | where-object { $_.name -like "*.msixbundle" } | Select-Object -ExpandProperty browser_download_url
65-
OutFile = "$env:TEMP\WinGet_$($latestVersion).msixbundle"
63+
OutFile = "$env:TEMP\WinGet_$($GithubInfoRestData.tag_name.Substring(1)).msixbundle"
6664
}
6765
}
6866
catch {
@@ -74,7 +72,10 @@
7472
}
7573

7674
# Checking if the installed version of WinGet are the same as the latest version of WinGet
77-
if ([Version]$WinGet -lt [Version]$GitHubInfo.Tag) {
75+
[version]$vWinGet = [string]$WinGet
76+
[version]$vGitHub = [string]$GitHubInfo.Tag
77+
78+
if ([Version]$vWinGet -lt [Version]$vGitHub) {
7879
Write-Output "WinGet has a newer version $($GitHubInfo.Tag), downloading and installing it..."
7980
Invoke-WebRequest -UseBasicParsing -Uri $GitHubInfo.DownloadUrl -OutFile $GitHubInfo.OutFile
8081

.src/private/function/Get-RSInstallInfo.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
# Collects everything in pscustomobject to get easier access to the information
5555
[System.Object]$SysInfo = [PSCustomObject]@{
5656
VCLibs = $(Get-AppxPackage -Name "Microsoft.VCLibs.140.00" -AllUsers | Where-Object { $_.Architecture -eq $Arch })
57-
WinGet = $(try { (Get-AppxPackage -AllUsers | Where-Object { $_.name -like "Microsoft.DesktopAppInstaller" }).version } catch { "no" })
57+
WinGet = $(try { (Get-AppxPackage -AllUsers | Where-Object { $_.name -like "Microsoft.DesktopAppInstaller" } | Sort-Object { $_.Version -as [version] } -Descending | Select-Object Version -First 1).version } catch { "no" })
5858
VisualCRedistUrl = $VisualCRedistUrl
5959
$VCLibsUrl = $VCLibsUrl
6060
Arch = $Arch

RSModuleBuilder.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[string]$Author = "Robin Stolpe"
55
[string]$Mail = "robin@stolpe.io"
66
[string]$Website = "https://stolpe.io"
7-
[string]$preRelease = "beta2"
7+
[string]$preRelease = ""
88
[string]$Company = "Stolpe.io"
99
[string]$apiKey = ""
1010
#

WinSoftwareUpdate/WinSoftwareUpdate.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
ReleaseNotes = 'https://github.com/rstolpe/WinSoftwareUpdate/releases'
135135

136136
# Prerelease string of this module
137-
Prerelease = 'beta2'
137+
Prerelease = ''
138138

139139
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
140140
RequireLicenseAcceptance = $false

WinSoftwareUpdate/WinSoftwareUpdate.psm1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,10 @@ Function Confirm-RSWinGet {
160160
[System.Object]$GithubInfoRestData = Invoke-RestMethod -Uri $GitHubUrl -Method Get -Headers $GithubHeaders -TimeoutSec 10 | Select-Object -Property assets, tag_name
161161
}
162162

163-
[string]$latestVersion = $GithubInfoRestData.tag_name.Substring(1)
164-
165163
[System.Object]$GitHubInfo = [PSCustomObject]@{
166-
Tag = $latestVersion
164+
Tag = $($GithubInfoRestData.tag_name.Substring(1))
167165
DownloadUrl = $GithubInfoRestData.assets | where-object { $_.name -like "*.msixbundle" } | Select-Object -ExpandProperty browser_download_url
168-
OutFile = "$env:TEMP\WinGet_$($latestVersion).msixbundle"
166+
OutFile = "$env:TEMP\WinGet_$($GithubInfoRestData.tag_name.Substring(1)).msixbundle"
169167
}
170168
}
171169
catch {
@@ -177,7 +175,10 @@ Function Confirm-RSWinGet {
177175
}
178176

179177
# Checking if the installed version of WinGet are the same as the latest version of WinGet
180-
if ([Version]$WinGet -lt [Version]$GitHubInfo.Tag) {
178+
[version]$vWinGet = [string]$WinGet
179+
[version]$vGitHub = [string]$GitHubInfo.Tag
180+
181+
if ([Version]$vWinGet -lt [Version]$vGitHub) {
181182
Write-Output "WinGet has a newer version $($GitHubInfo.Tag), downloading and installing it..."
182183
Invoke-WebRequest -UseBasicParsing -Uri $GitHubInfo.DownloadUrl -OutFile $GitHubInfo.OutFile
183184

@@ -244,7 +245,7 @@ Function Get-RSInstallInfo {
244245
# Collects everything in pscustomobject to get easier access to the information
245246
[System.Object]$SysInfo = [PSCustomObject]@{
246247
VCLibs = $(Get-AppxPackage -Name "Microsoft.VCLibs.140.00" -AllUsers | Where-Object { $_.Architecture -eq $Arch })
247-
WinGet = $(try { (Get-AppxPackage -AllUsers | Where-Object { $_.name -like "Microsoft.DesktopAppInstaller" }).version } catch { "no" })
248+
WinGet = $(try { (Get-AppxPackage -AllUsers | Where-Object { $_.name -like "Microsoft.DesktopAppInstaller" } | Sort-Object { $_.Version -as [version] } -Descending | Select-Object Version -First 1).version } catch { "no" })
248249
VisualCRedistUrl = $VisualCRedistUrl
249250
$VCLibsUrl = $VCLibsUrl
250251
Arch = $Arch

test/PSScriptAnalyzer_WinSoftwareUpdate.psm1_2023-01-18.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RuleSuppressionID :
1111
SuggestedCorrections :
1212
IsSuppressed : False
1313

14-
Line : 306
14+
Line : 307
1515
Column : 10
1616
Message : Function 'Start-RSWinGet' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'.
1717
Extent : Start-RSWinGet

0 commit comments

Comments
 (0)