NuGet version number formatting restrictions

KB#1157: Last Updated Feb 22, 2018

SemVer2 versions

SemVer2, or Semantic Versioning 2.0.0 version numbers are supported only in SemVer2 (ProGet 5+) NuGet feeds.

A formal description is available in the Semantic Versioning 2.0.0 specification.

A SemVer2 version number is three decimal integers (digits 0-9) separated by dots (.). Each component of the version number must not begin with a zero (0) unless it is exactly 0 (not 00 or 000, etc.).

Additionally, a semantic version number may contain a pre-release indicator and build metadata.

Pre-release indicators begin with a hyphen (-) and consist of one or more dot-separated (.) parts, which must not be empty and may contain letters (a-z, A-Z), digits (0-9), and hyphens (-). If a component of a pre-release indicator contains only digits, it must follow the same no-leading-zeroes rule listed above.

Build metadata begins with a plus sign (+) and may contain any of the characters that pre-release indicators are allowed to contain. The components of a build metadata string must not be empty, but there is no restriction for leading zeroes. Build metadata is ignored when comparing version numbers, so 1.2.3+foo and 1.2.3+bar are considered to be the same version.

If both a pre-release indicator and build metadata are present, the pre-release indicator must come first.

Legacy versions

Legacy version numbers are supported in both legacy (ProGet 4) NuGet feeds and SemVer2 (ProGet 5+) NuGet feeds.

Legacy version numbers consist of one to four decimal integers (digits 0-9) separated by dots (.).

They can also optionally have a pre-release indicator, which is a hyphen (-) followed by a sequence of letters (a-z, A-Z), digits (0-9), and hyphens (-). Pre-release indicators must be at least one character long and must start with a letter.