Search code examples
nugetversionpush

Nuget '2.0.20180607160057-jenkins' is not a valid version string


I have a scripted NuGet push that refuses to push my NuGet package:

"%NUGET%" push *.nupkg -Source "%NUGETREPO%"

The error I encounter is:

'2.0.20180607160057-jenkins' is not a valid version string.
Parametername: value

Solution

  • While writing the question I dug down the rabbit hole to an obvious end.

    The relevant implementation is here https://github.com/NuGet/NuGet2/ ... /src/Core/SemanticVersion.cs

    ^(?<Version>\d+(\s*\.\s*\d+){0,3})(?<Release>-[a-z][0-9a-z-]*)?$
    ^(?<Version>\d+(\.\d+){2})(?<Release>-[a-z][0-9a-z-]*)?$
    

    When I feed 2.0.20180607160057-jenkins into an online Regex Tester The string passes both regex tests. The online regex even allows me to toggle Ignore Case and Explicit Capture.

    The next deeper level is in

    Version.TryParse(match.Groups["Version"].Value, out versionValue)
    

    The System.Version.TryParse is documented here. No Version can be smaller than 0 or bigger than Int32.MaxValue. So this particular failure boils down to

    2147483647 < 20180607160057
    

    fairly intuitive actually - and I need a different scheme to generate my patch level for nuget.