Powershell: Can we improve the semantic version implementation for myget?

Created on 24 Sep 2016  路  12Comments  路  Source: PowerShell/PowerShell

A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version.

http://semver.org/

Two things I'd propose improving.

First, current releases on MyGet are being labelled badly. For instance, SMA is "1.0.0-alpha10" or "1.0.0-alpha9" ...

  1. I'm pretty sure that should be 6.0.0?
  2. I think the pre-release section should be -alpha.9 and -alpha.10

Second, the System.Management.Automation.SemanticVersion built into PowerShell 6 can't sort pre-releases into the right order ... because it treats everything on the end as a _single_ text label and sorts them alphabetically (so, like Visual Studio, it thinks the "1.0.0-alpha9" is newer than "1.0.0-alpha10").

Area-Maintainers-Build Issue-Question

All 12 comments

I would suggest having the SMA.SemanticVersion be a separate issue

@daxian-dbw can you, please comment on the "." in pre-release part?
Together with alpha.11, we will remove alpha9 package from myget feed to fix the order.

@Jaykul yes, we spotted this awkward issue in powershell-core myget, and I'm sorry for not thinking through when publishing the alpha9 packages.
As for the '.', nuget treats version tags like "1.0.0-alpha.05" as invalid, and package with that version tag cannot be opened by tools like "Nuget Package Explorer".

PS:80> cat .\test.nuspec -TotalCount 6
<?xml version="1.0"?>
<package >
    <metadata>
        <id>test</id>
        <version>1.0.0-alpha.05</version>
        <title>test</title>
PS:81> nuget pack .\test.nuspec
Attempting to build package from 'test.nuspec'.
'1.0.0-alpha.05' is not a valid version string.
Parameter name: value

Ok, I just double-checked, and I see that even though feeds on MyGet have support for Semver 2, _after 2 years_, SemVer 2 had been _deliberately blocked_ in nuget pack. It used to work and this bug has been fixed

The current state is confusing -- at best.

I thought this was working in dotnet pack?

I guess you should wait for NuGet 3.5 and then implement Semver 2 -- it's already supported server-side on MyGet, and client-side in NuGet (except for packing).

@daxian-dbw 1.0.0-alpha.05 contains a leading zero on a release label which makes it invalid. Try: 1.0.0-alpha.5 or if you really want the zero, 1.0.0-alpha-05

See http://semver.org/#spec-item-9 for more on the release label rules

@emgarten thanks for pointing it out. I tried 1.0.0-alpha.5 and it doesn't work even with the latest v3.5.0-rc1 nuget.exe:

PS:38> cat .\test.nuspec -TotalCount 6
<?xml version="1.0"?>
<package >
    <metadata>
        <id>test</id>
        <version>1.0.0-alpha.5</version>
        <title>test</title>
PS:39> E:\arena\nupkg\NuGet.exe pack .\test.nuspec
Attempting to build package from 'test.nuspec'.
Versions using SemVer 2.0.0 are not supported: 1.0.0-alpha.5.
PS:40> E:\arena\nupkg\NuGet.exe | select -First 1
NuGet Version: 3.5.0.1737

I like 1.0.0-alpha-11 though. Maybe we should go with hyphen?

@daxian-dbw use the latest NuGet.exe here: https://dotnet.myget.org/feed/nuget-build/package/nuget/NuGet.CommandLine/3.5.0-rtm-1829

3.5.0-rc1 had SemVer 2.0.0 blocked, but that was changed after rc1.

Thanks @emgarten, the rtm build works, though with warning about incompatibility with old client:

Attempting to build package from 'test.nuspec'.
Successfully created package 'E:\arena\nupkg\temp\test.1.0.0-alpha.5.nupkg'.
WARNING: Issue found with package 'test'.

WARNING: Issue: Package version not supported on legacy clients.
WARNING: Description: The package version '1.0.0-alpha.5' uses SemVer 2.0.0 or components of SemVer 1.0.0 that are not supported on legacy clients. This message can be ignored if the package is not intended for older clients.
WARNING: Solution: Change the package version to a SemVer 1.0.0 string. If the version contains a release label it must start with a letter.

dotnet-cli works with 1.0.0-alpha.5 nuget package, but the latest "Nuget Package Explorer" v3.18 doesn't because it's compatible only with nuget 2.8.1 and below.

That's such a shame ;-)

(Ah wouldn't life have been simpler with 0.11.0? 馃槈)

As discussed, add the . so we can close this out. The rest of SemVer is covered in #2983

The . has been added to $PSVersionTable and the filename

Was this page helpful?
0 / 5 - 0 ratings