[Bug]: Nightly package versions do not sort by build time

未关闭 适合新手
#447 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
csharp, github-actions
领域
ci-cd, release

调研方向

从工作流文件 ci.yml 开始,找到名为“Compute version suffix”的步骤,该步骤将 VersionSuffix 写入 $GITHUB_ENV。把它改为提案中的定宽 UTC 时间戳,并在构建步骤中通过 -p:SourceRevisionId 传入提交 SHA,使其出现在 InformationalVersion 中。当同一天的新 nightly 版本排序高于较早的构建,且 SHA 仅作为构建元数据出现时,即完成。可以在本地或通过工作流试运行执行打包步骤来检查结果。

由索引模型根据 Issue 内容生成。

描述

Bug good first issue

Problem

Nightly packages get a version suffix of the build date plus the commit SHA (ci.yml, "Compute version suffix"):

echo "VersionSuffix=$(date +'%Y%m%d')-${GITHUB_SHA::7}" >> "$GITHUB_ENV"

Within one day, versions are ordered by the SHA, which is random. NuGet compares 20261102-8979913 and 20261102-800815c as strings (SemVer alphanumeric identifiers), and 9 > 0, so the older build counts as higher:

Version Published NuGet order
1.0.0-alpha.20261102-8979913 14 hours ago higher
1.0.0-alpha.20261102-800815c 12 hours ago lower

As a result:

  • dotnet tool install --global RazorConsole.Cli --version 1.0.0-alpha.20261102-800815c fails with "the requested version is lower than the installed version" when the older build is installed; it needs dotnet tool update --allow-downgrade.
  • dotnet tool update, dotnet add package --prerelease and Dependabot can pick an older build of the same day as the "latest".

This affects every package built with this suffix, not only RazorConsole.Cli.

Proposal

Use a fixed-width UTC timestamp instead of the SHA, keeping the hyphen:

echo "VersionSuffix=$(date -u +'%Y%m%d-%H%M%S')" >> "$GITHUB_ENV"
  • The identifier stays alphanumeric and fixed-width, so string comparison follows build time.
  • New versions sort above every version already published (except other builds of 2026-11-02, which is in the past).
  • Keep the commit in the package as build metadata: pass -p:SourceRevisionId=${GITHUB_SHA} so it ends up in InformationalVersion (1.0.0-alpha.20261103-083000+<sha>). Build metadata does not affect version ordering.

A purely numeric suffix (for example $(date +%Y%m%d).${GITHUB_RUN_NUMBER}) would sort correctly among new builds, but SemVer ranks numeric identifiers below alphanumeric ones. All new builds would then rank below the versions already published, so it should not be used without a version bump.

Workaround

dotnet tool update --global RazorConsole.Cli --version <version> --allow-downgrade
主要语言
C#
星标
1.7k
派生
51
平均合并
2 天 6 小时
30 天内合并 PR
40

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

RazorConsole/RazorConsole 的其他 Issue

查看 RazorConsole/RazorConsole 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。