20 lines
941 B
C#
20 lines
941 B
C#
namespace MoShiro.Protocol;
|
|
|
|
/// <summary>构建信息的人能读的形式(启动时打进日志);常量部分由 MoShiro.Protocol.csproj 的 WriteBuildInfo 在构建时生成。</summary>
|
|
public static partial class BuildInfo
|
|
{
|
|
/// <summary>版本、tag、提交、构建时间的字段,没有的(本地构建不设环境变量)写 unknown。</summary>
|
|
public static (string Key, object? Value)[] Fields { get; } =
|
|
[
|
|
("version", Or(Version)),
|
|
("tag", Or(Tag)),
|
|
("commit", Or(Commit)),
|
|
("built_at", Or(BuiltAt)),
|
|
];
|
|
|
|
/// <summary>一行摘要,例如:0.4.1-dev.2-a3338e1 (tag v0.4.1-dev.2-a3338e1, commit a3338e1b2c, built 2026-10-09T03:00:00Z)。</summary>
|
|
public static string Summary => $"{Or(Version)} (tag {Or(Tag)}, commit {Or(Commit)}, built {Or(BuiltAt)})";
|
|
|
|
private static string Or(string value) => string.IsNullOrWhiteSpace(value) ? "unknown" : value;
|
|
}
|