noz-cli/NozCli/VersionInfo.cs
kryptomrx 74bc28bce4 feat(build): Native AOT publish, versioning with git hash
- PublishAot=true, InvariantGlobalization=true, AssemblyName=noz
- Version 0.1.0 baked into binary via AssemblyInformationalVersion
- MSBuild target injects git short hash as SourceRevisionId at build time
- macOS: LinkerArg for Homebrew OpenSSL path (required for AOT linking)
- noz --version / -v exits cleanly without starting the REPL
2026-05-16 23:21:14 +02:00

26 lines
801 B
C#

using System.Reflection;
namespace NozCli;
public static class VersionInfo
{
private static readonly string _informational =
typeof(VersionInfo).Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion ?? "0.0.0";
// "0.1.0+abc1234" → "0.1.0"
public static string Version =>
_informational.Contains('+')
? _informational[.._informational.IndexOf('+')]
: _informational;
// "0.1.0+abc1234" → "abc1234", or "" if no hash
public static string GitHash =>
_informational.Contains('+')
? _informational[(_informational.IndexOf('+') + 1)..]
: "";
public static string Full =>
GitHash.Length > 0 ? $"{Version} ({GitHash})" : Version;
}