PSResourceInfo object does not properly sort versions
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
Steps to reproduce
I should be able to sort resources by their version but this does not work as expected. This does not work due to PowerShellGet 3.0.11-beta splitting up semantic versioning into two different properties Version
[System.Version]
and PrereleaseLabel
[String]
on the PSResourceInfo
type.
PowerShellGet 3.0.11-beta already takes a dependency on Nuget.Versioning.dll
which contains [NuGet.Versioning.NuGetVersion]
type that can handle traditional [Version]
as well as [SemanticVersion]
.
Related issue https://github.com/PowerShell/PowerShell/issues/2983, https://github.com/PowerShell/PowerShellGet/issues/83
cc: @jaykul
Expected behavior
Should be able to properly sort resources by version.
Actual behavior
Sorting does not take into account semantic versioning.
Error details
No response
Environment data
PS C:\> Get-Module -Name PowerShellGet
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Binary 3.0.11 beta PowerShellGet {Find-PSResource, Get-InstalledPSResource, Get-PS…
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 7.2.0-preview.8
PSEdition Core
GitCommitId 7.2.0-preview.8
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
PSResourceInfo object does not properly sort versions #459
I should be able to sort resources by their version but this does not work as expected. This does not work due to...
Read more >Complete the SemanticVersion work · Issue #2983
Can we improve the semantic version implementation for myget? #2354 ... PSResourceInfo object does not properly sort versions ...
Read more >Sort a list that contains version numbers properly
Sort -Object then sorts the filtered tags as version numbers, which yields ... Version] instances; simply remove it first (not from the input ......
Read more >Version field sort order not working properly
I have a document library with versioning, and I am tweaking the view through the UI. It appears that, right ootb, when we...
Read more >PowerShell Training: Sorting Version Numbers
Sorting version numbers as strings can fail to order them correctly, but the [Version]. type accelerator can be used to sort them correctly....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
tl;dr: These objects should have a
SemanticVersion
property so we can sort by that.To make
| Sort Version
work the way it’s described, you would have to change theVersion
property.But let’s try to think about this a different way. Imagine that you actually followed SemVer with this module…
Instead of this:
You would have published:
So, if we had those three packages in a
$Modules
array and we wanted to invert the sort order so the newest is last, how would we do that? Currently, we can’t unless we create a new property to sort by:So that we can do this:
Thanks @ThomasNieto! We will make this change soon, we will try to get this in for the next release as well.