我在下面看到:
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
被认为是下面任何地方提到的发布版本:
最佳答案
预发布版本的定义是什么?
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在问题的评论中提到,NuGet 正在为其以前支持的内容添加向后兼容性支持。事实上,这是在 2011 年将 SemVer 支持添加到 NuGet 中的提交:https://github.com/NuGet/NuGet2/commit/a999416414071f321f1ad5aa6d8c744ba0715e3a
从众多文件中我们可以看出,NuGet在此之前使用的是System.Version
作为包版本,从System.Version
's docs可以看出它包含这个 4 段版本。 SemVer.cs
的第一个版本包含 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
,扩展了一个严格的 semver2 SemanticVersion
,但是 this comment still exists to this day .
结论
因此,虽然 SemVer2 的预发布定义明确要求连字符紧跟补丁版本,但向后兼容性阻止了 NuGet,即使在最初发布后仅 1 年,也无法完全符合 SemVer2 的要求。
因此,需要对 SemVer2 进行一些重新解释,选择是将连字符作为预发布信号,不超过 3 个片段。 9 年后,这就是我们所拥有的,nuget.org 上有数以千计的包使用 4 段版本,其中一些带有额外的预发布标签。
关于nuget - 为什么 nuget 将 1.2.3.4 视为稳定(发布)版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64543938/