From 3a7fd9d288ae297874ede1d3cc18dcfa6b96eb52 Mon Sep 17 00:00:00 2001 From: Sean Williams <72675818+sean-r-williams@users.noreply.github.com> Date: Fri, 27 Feb 2026 20:40:28 -0800 Subject: [PATCH 1/3] `Update-PSResource`: Include local-copy prerelease string in update-scope determination --- src/code/UpdatePSResource.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/code/UpdatePSResource.cs b/src/code/UpdatePSResource.cs index 29792ab71..9656ff053 100644 --- a/src/code/UpdatePSResource.cs +++ b/src/code/UpdatePSResource.cs @@ -390,7 +390,8 @@ private string[] ProcessPackageNames( } // If the current package is out of range, install it with the correct version. - if (!NuGetVersion.TryParse(installedPackage.Version.ToString(), out NuGetVersion installedVersion)) + string installedVersionString = Utils.GetNormalizedVersionString(installedPackage.Version.ToString(), installedPackage.Prerelease); + if (!NuGetVersion.TryParse(installedVersionString, out NuGetVersion installedVersion)) { WriteWarning($"Cannot parse nuget version in installed package '{installedPackage.Name}'. Cannot update package."); continue; From fe4eb3935195195b90c5fb36137b404529edf9fa Mon Sep 17 00:00:00 2001 From: anamnavi Date: Tue, 12 May 2026 16:34:07 -0400 Subject: [PATCH 2/3] Add test for fix using TestModulePrerelease --- .../UpdatePSResourceV2.Tests.ps1 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 b/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 index cd50abcf1..e2d81aa65 100644 --- a/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 +++ b/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 @@ -13,13 +13,14 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { $testModuleName = "test_module" $testModuleName2 = "test_module2" $testModuleName3 = "TestModule99" + $testModuleName4 = "TestModulePrerelease" $PackageManagement = "PackageManagement" Get-NewPSResourceRepositoryFile Get-PSResourceRepository } AfterEach { - Uninstall-PSResource "test_module", "TestModule99", "TestModuleWithLicense", "test_module2", "test_script" -Version "*" -ErrorAction SilentlyContinue -SkipDependencyCheck + Uninstall-PSResource "test_module", "TestModule99", "TestModuleWithLicense", "test_module2", "test_script", "TestModulePrerelease" -Version "*" -ErrorAction SilentlyContinue -SkipDependencyCheck } AfterAll { @@ -210,6 +211,20 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { $isPkgUpdated | Should -Be $true } + It "Update prerelease version to next version when prerelease label is only differing factor between versions" { + # $testModuleName4 (TestModulePrerelease) has versions: 0.0.4-beta, 0.0.4. Updating should respect prerelease label + Install-PSResource -Name $testModuleName4 -Version "0.0.4-beta" -Repository $PSGalleryName -TrustRepository + $res = Get-InstalledPSResource -Name $testModuleName4 + $res.Name | Should -Be $testModuleName4 + $res.Version | Should -Contain "0.0.4" + $res.Prerelease | Should -Be "beta" + + Update-PSResource -Name $testModuleName4 -Repository $PSGalleryName -TrustRepository + $res2 = Get-InstalledPSResource -Name $testModuleName4 + $res2.Version | Should -Contain "0.0.4" + $res2.Prerelease | Should -BeNullOrEmpty + } + # Windows only It "update resource under CurrentUser scope" -skip:(!($IsWindows -and (Test-IsAdmin))) { # TODO: perhaps also install TestModule with the highest version (the one above 1.2.0.0) to the AllUsers path too From 0d9eacf702df869651cb4d763018fe6253680d3f Mon Sep 17 00:00:00 2001 From: anamnavi Date: Tue, 12 May 2026 17:16:27 -0400 Subject: [PATCH 3/3] Use newly named GetThreeDigitNormalizedVersionString() method --- src/code/UpdatePSResource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code/UpdatePSResource.cs b/src/code/UpdatePSResource.cs index 9656ff053..4d44d2b52 100644 --- a/src/code/UpdatePSResource.cs +++ b/src/code/UpdatePSResource.cs @@ -390,7 +390,7 @@ private string[] ProcessPackageNames( } // If the current package is out of range, install it with the correct version. - string installedVersionString = Utils.GetNormalizedVersionString(installedPackage.Version.ToString(), installedPackage.Prerelease); + string installedVersionString = Utils.GetThreeDigitNormalizedVersionString(installedPackage.Version.ToString(), installedPackage.Prerelease); if (!NuGetVersion.TryParse(installedVersionString, out NuGetVersion installedVersion)) { WriteWarning($"Cannot parse nuget version in installed package '{installedPackage.Name}'. Cannot update package.");