diff --git a/BuildTime.ps1 b/BuildTime.ps1 new file mode 100644 index 0000000..cf10aba --- /dev/null +++ b/BuildTime.ps1 @@ -0,0 +1,3 @@ +$buildTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss" +$buildTime | Out-File -FilePath "BuildTime.txt" -Encoding UTF8 +Write-Host "Build time written to BuildTime.txt: $buildTime" diff --git a/BuildTime.txt b/BuildTime.txt new file mode 100644 index 0000000..d2aaee1 --- /dev/null +++ b/BuildTime.txt @@ -0,0 +1 @@ +2026-02-12 00:49:53 diff --git a/CMLeonOS.csproj b/CMLeonOS.csproj index 6f913d3..f6b767f 100644 --- a/CMLeonOS.csproj +++ b/CMLeonOS.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -70,6 +70,7 @@ + @@ -93,6 +94,7 @@ + diff --git a/GitCommit.txt b/GitCommit.txt index 5858063..d60a22b 100644 --- a/GitCommit.txt +++ b/GitCommit.txt @@ -1 +1 @@ -b80c5b4 \ No newline at end of file +269c61f \ No newline at end of file diff --git a/Kernel.cs b/Kernel.cs index beb94e7..29436a9 100644 --- a/Kernel.cs +++ b/Kernel.cs @@ -43,6 +43,9 @@ namespace CMLeonOS [IL2CPU.API.Attribs.ManifestResourceStream(ResourceName = "CMLeonOS.GitCommit.txt")] public static readonly byte[] gitCommitFile; + [IL2CPU.API.Attribs.ManifestResourceStream(ResourceName = "CMLeonOS.BuildTime.txt")] + public static readonly byte[] buildTimeFile; + public static void ShowError(string message) { Console.ForegroundColor = ConsoleColor.Red; @@ -142,6 +145,24 @@ namespace CMLeonOS _logger.Warning("Kernel", "Git Commit file not found, using 'unknown'"); } + // 读取 Build Time + if (buildTimeFile != null && buildTimeFile.Length > 0) + { + try + { + string buildTime = System.Text.Encoding.UTF8.GetString(buildTimeFile); + _logger.Info("Kernel", $"Build Time: {buildTime}"); + } + catch + { + _logger.Warning("Kernel", "Failed to read Build Time"); + } + } + else + { + _logger.Warning("Kernel", "Build Time file not found"); + } + // 检查env.dat文件是否存在,如果不存在则创建并设置Test环境变量 string envFilePath = @"0:\system\env.dat"; if (!System.IO.File.Exists(envFilePath)) diff --git a/docs/cmleonos/docs/commands.md b/docs/cmleonos/docs/commands.md index 8fabdfc..c4aa55c 100644 --- a/docs/cmleonos/docs/commands.md +++ b/docs/cmleonos/docs/commands.md @@ -691,6 +691,18 @@ unalias ll version ``` +**输出:** +``` +CMLeonOS v1.0.0 (PreRelease 2) - Git: b80c5b4 +Major: 1 +Minor: 0 +Patch: 0 +Type: PreRelease 2 +Full Version: 1.0.0-PreRelease 2 +Git Commit: b80c5b4 +Build Time: 2026-02-12 15:30:45 +``` + ### settings 查看或修改系统设置。 diff --git a/shell/Commands/Info/Version.cs b/shell/Commands/Info/Version.cs index f02506b..76ba58e 100644 --- a/shell/Commands/Info/Version.cs +++ b/shell/Commands/Info/Version.cs @@ -1,11 +1,16 @@ using System; +using IL2CPU.API.Attribs; namespace CMLeonOS.Commands { public static class VersionCommand { + [ManifestResourceStream(ResourceName = "CMLeonOS.BuildTime.txt")] + private static byte[] buildTimeResource; + public static void ProcessVersion() { + string buildTime = global::System.Text.Encoding.UTF8.GetString(buildTimeResource); Console.WriteLine(Version.DisplayVersionWithGit); Console.WriteLine($"Major: {Version.Major}"); Console.WriteLine($"Minor: {Version.Minor}"); @@ -13,6 +18,7 @@ namespace CMLeonOS.Commands Console.WriteLine($"Type: {Version.VersionType}"); Console.WriteLine($"Full Version: {Version.FullVersion}"); Console.WriteLine($"Git Commit: {Version.GitCommit}"); + Console.WriteLine($"Build Time: {buildTime}"); } } }