Skip to content

SMA SemanticVersion not SemVer 2 compliant #5004

Closed

Description

@Jaykul

First: System.Management.Automation.SemanticVersion is not SemVer v2 compliant

Second: PowerShell releases are using SemVer v2 syntax

Therefore: $PSVersionTable.PSVersion is truncated and thus broken, as pre-release versions cannot be compared to each other (the only useful assertion possible is that the PSVersion is -lt "6.0.0")

You should be using (an implementation like) Nuget.Core's Nuget.SemanticVersion which handles -prerelease and +patch as well as dotted versions like your 6.0.0-beta.7

Note that both the tests below return TRUE if $SemVer is Nuget.SemanticVersion:

Steps to reproduce

$SemVer = [System.Management.Automation.SemanticVersion]
("6.0.0-beta.10" -as $SemVer) -gt ("6.0.0-beta.7" -as $SemVer)
("6.0.0+fixes" -as $SemVer) -gt ("6.0.0-beta" -as $SemVer)

Expected behavior

True
True

Actual behavior

False
False

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.7
OS                             Microsoft Windows 10.0.15063
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    WG-Engine
    on Oct 4, 2017
  2. added this to the milestone on Oct 4, 2017
  3. iSazonov commented on Oct 5, 2017

    @iSazonov
    Collaborator

    Dongbo Wang (@daxian-dbw) We discussed PSVersionTable.PSVersion in previous PR - could you please comment the Issue?

  4. iSazonov commented on Oct 5, 2017

    @iSazonov
    Collaborator

    Fix for compare is ready.

  5. modified the milestones: , 6.0.0-RC on Nov 3, 2017
  6. added
    Backport-5.1-Consider
    on Nov 14, 2017
  7. removed
    Backport-5.1-Consider
    on Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Resolution-FixedWG-Engine

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions