为什么 nuget 将 1.2.3.4 视为稳定(发布)版本?

Why does nuget consider 1.2.3.4 to be a stable (release) version?

我在下面看到:

1.2.3          // release
1.2.3+hash     // release
1.2.3-alpha    // pre-release
1.2.3-alpha.12 // pre-release

1.2.3.4        // why is this release version and not pre-release version or invalid?
1.2.3.4.5      // invalid nuget version

我不明白为什么 1.2.3.4 被认为是以下任何地方提到的发行版本:

pre-release 版本的定义是什么?

NuGet(大部分)符合 SemVer2,如其网站上所定义:https://semver.org/

第 9 节开始:https://semver.org/#spec-item-9

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

但是 SemVer2 不允许 4 段版本

正确,但是 Joe Sewell mentioned in the question's comment, NuGet was adding backwards compatibility support for what it previously supported. In fact, here's the commit that added SemVer support into NuGet, back in 2011: https://github.com/NuGet/NuGet2/commit/a999416414071f321f1ad5aa6d8c744ba0715e3a

从众多文件中我们可以看出,NuGet在此之前是使用System.Version作为包版本的,从System.Version's docs that it contains this 4 segment version. The very first version of SemVer.cs contained the comment:

中可以看出

A hybrid implementation of SemVer that supports semantic versioning as described at http://semver.org while not strictly enforcing it to allow older 4-digit versioning schemes to continue working.

该文件后来被重命名为SemanticVersion,后来拆分成一个NuGetVersion,扩展了一个strictly-semver2 SemanticVersion,但是this comment still exists to this day.

结论

因此,虽然 SemVer2 的 pre-release 定义明确要求连字符紧跟补丁版本,但向后兼容性阻止了 NuGet,即使在最初发布后仅 1 年,也无法完全符合 SemVer2 的要求。

因此,需要对 SemVer2 进行一些重新解释,选择是将连字符设为 pre-release 信号,不超过 3 个片段。 9 年后,这就是我们所拥有的,nuget.org 上有数以千计的软件包使用 4 段版本,一些带有额外的预发布标签。