Skip to content

Update-PSResource: Include local-copy prerelease string when deciding update applicability#1954

Merged
anamnavi merged 3 commits into
PowerShell:masterfrom
sean-r-williams:1953_update-psresource-prerelease-to-full-release
May 19, 2026
Merged

Update-PSResource: Include local-copy prerelease string when deciding update applicability#1954
anamnavi merged 3 commits into
PowerShell:masterfrom
sean-r-williams:1953_update-psresource-prerelease-to-full-release

Conversation

@sean-r-williams
Copy link
Copy Markdown
Contributor

@sean-r-williams sean-r-williams commented Feb 28, 2026

PR Summary

This PR updates Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource to consider a locally-installed resource's prerelease string when comparing against the repository's available versions.

Fixes #1953.

PR Context

Currently, Update-PSResource only considers the locally-installed resource's version component from the PSResourceInfo.Version field, of type System.Version. This struct doesn't include prerelease strings - PSResourceInfo.Prerelease contains those.

This means that if I have:

  • A locally-installed resource, with version 1.0.1-pre
  • A remote repository resource, with version 1.0.1
  • The same version number between the two (sans prerelease - i.e. the module's prerelease "graduated")
    ...then Update-PSResource will mistakenly mark the locally-installed version as "up to date".

JiraPS, which recently released 2.15.0 (having previously released 2.15.0-alpha1 in 2024), falls into this bucket.

This behavior needs a test. Publishing a test module to Gallery with a prerelease, then normal-release version (i.e. 1.0.1-pre and 1.0.1) would be enough to test this behavior.

If someone from the Gallery team can publish a test module, I'm happy to contribute a test to test\UpdatePSResourceTests\UpdatePSResourceV2.Tests.ps1 as part of this PR.

PR Checklist

@kilasuit
Copy link
Copy Markdown

kilasuit commented Mar 20, 2026

@sean-r-williams re this

This behavior needs a test. Publishing a test module to Gallery with a prerelease, then normal-release version (i.e. 1.0.1-pre and 1.0.1) would be enough to test this behavior.

If someone from the Gallery team can publish a test module, I'm happy to contribute a test to test\UpdatePSResourceTests\UpdatePSResourceV2.Tests.ps1 as part of this PR.

I'd just write a test against the available PSResourceGet versions as opposed to creating other test modules for this as PSResourceGet does have pre-release and non-prerelease versions as I can't see the team delisting a version unless really needed

Copy link
Copy Markdown
Member

@anamnavi anamnavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this bugfix @sean-r-williams and my apologies for the delay in getting to it! I've linked the upstream branch/PR here where I'm running tests, but you'll notice I've published the module version as you mentioned and added a test. You'll want to rebase your branch and add that test, thanks!

Copilot AI review requested due to automatic review settings May 19, 2026 16:27

This comment was marked as outdated.

@anamnavi anamnavi force-pushed the 1953_update-psresource-prerelease-to-full-release branch from efe91a6 to dd01ee0 Compare May 19, 2026 16:45
@anamnavi anamnavi force-pushed the 1953_update-psresource-prerelease-to-full-release branch from dd01ee0 to 099e24a Compare May 19, 2026 16:53
@sean-r-williams
Copy link
Copy Markdown
Contributor Author

@anamnavi Apologies, I changed teams at the start of April and my day-to-day interaction with PowerShell has decreased while re-ramping.

I think 3758ffb captures the test I was going to write, so I'm not sure if there's any action I can take here. Let me know if you need me to rebase or anything.

Copy link
Copy Markdown
Member

@anamnavi anamnavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the contribution @sean-r-williams !

@anamnavi anamnavi merged commit ec514d7 into PowerShell:master May 19, 2026
1 check passed
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.

Update-PSResource fails to upgrade same-version prerelease -> full release

5 participants