Search code examples
.net-corenuget

NugGet Semver - what are allowed prerelease characters?


I'm trying to use semantic versioning for one of my NuGet Packages (.NET Core 2).

The version looks like this: 1.0.0-my_fancy_branch.123.

As you can guess, I try to set the branch name and the current BuildId as a prerelease tag.

Unfortunately, dotnet build spews this error:

... is not a valid version string.

But why? The absolutely great documentation of dotnet push / nuget does not list any forbidden characters.


Solution

  • According to the reference on NuGet package versions, NuGet uses Semantic Versioning 2.0.0 starting with NuGet 4.3.0. In earlier versions only a subset of SemVer 2.0.0 is supported, but this may still give a hint where the problem with the specified version is.

    In Section 9 (about pre-release versions) it is specified that

    Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-].

    Hence, I guess that the problems in your case are the underscores in the pre-release version.