PSResourceGet
PSResourceGet copied to clipboard
NuGet API v2 `Find-PSResource -Prerelease` does not return prerelease if there is any newer stable release(s)
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest released version
- [X] Search the existing issues.
Steps to reproduce
PowerShell Gallery / NuGet API v2 Find-PSResource -Prerelease -Name 'Az.Accounts' returns a stable release rather than a prerelease.
I expect this cmdlet to return the newest prerelease version, even if there's newer stable release(s) available.
- Az.Accounts in PowerShell gallery: https://www.powershellgallery.com/packages/Az.Accounts
- Doc on
-Prereleaseparameter: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.psresourceget/find-psresource?view=powershellget-3.x#-prerelease
Observation
Doing Find-PSResource -Name 'Az.Accounts' -Prerelease -Debug tells us that PSResourceGet does a GET to:
Which indeed just returns the absolute newest version, whether it's a prerelease or not.
Workaround
Following URL in my testing returns the newest prerelease, and does not care if newer stable release(s) exsists.
This works if asking for one package Id at a time. Don't know if it's possible to achieve this if asking for multiple Ids in the same request.
Expected behavior
Return newest prerelease version
Actual behavior
Returns absolute latest version, whether it's a prerelease or not.
Error details
No response
Environment data
Not relevant.
Visuals
No response
IMO, -Prerelease is misleading. It does not neccessarly get a prerelase version, but means IsAbsoluteLatestVersion in the PS Gallery API (NuGet v2). In other words: Get the absolute newest version, even if it's prerelease.
Suggestions:
- Add a new switch
-PrereleaseOnlywhich does$filter=IsPrerelease&$orderby=Version%20desc&$top=1. - Add alias to
-Prerelease:-IncludePrereleaseand-AbsoluteLatestVersion.- Removing or changing behavior of
-Prereleasewould probably be too radical, even though it's not behaving as one would expect?
- Removing or changing behavior of