From 609accc96e7269bca8672a3ffded37b240c9f386 Mon Sep 17 00:00:00 2001 From: doudou0720 <98651603+doudou0720@users.noreply.github.com> Date: Sat, 16 May 2026 18:42:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(build):=20=E9=85=8D=E7=BD=AE=E4=BD=BF?= =?UTF-8?q?=E7=94=A8Nerdbank.GitVersioning=E8=87=AA=E5=8A=A8=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 添加Directory.Build.props引入Nerdbank.GitVersioning包 2. 创建version.json配置版本规则 3. 禁用各项目手动AssemblyInfo生成,改用自动版本 4. 更新AboutPage和启动界面显示带Git短哈希的版本信息 5. 清理冗余的手动版本属性和AssemblyInfo内容 Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> --- Directory.Build.props | 9 +++++ Ink Canvas/App.xaml.cs | 14 ++++++- Ink Canvas/AssemblyInfo.cs | 18 +-------- Ink Canvas/InkCanvasForClass.csproj | 14 ++++--- Ink Canvas/Properties/AssemblyInfo.cs | 38 +------------------ .../SettingsViews/Pages/AboutPage.xaml.cs | 13 ++++++- Ink Canvas/Windows/SplashScreen.xaml.cs | 14 ++++++- Ink Canvas/packages.lock.json | 6 +++ InkCanvas.Controls/InkCanvas.Controls.csproj | 1 + .../InkCanvas.IACoreHelper.csproj | 1 + .../Properties/AssemblyInfo.cs | 2 - .../InkCanvas.PluginSdk.csproj | 1 + version.json | 27 +++++++++++++ 13 files changed, 95 insertions(+), 63 deletions(-) create mode 100644 Directory.Build.props create mode 100644 version.json diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 00000000..f9cd8ce0 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,9 @@ + + + + + all + 3.9.50 + + + \ No newline at end of file diff --git a/Ink Canvas/App.xaml.cs b/Ink Canvas/App.xaml.cs index 984a4e87..12def1d4 100644 --- a/Ink Canvas/App.xaml.cs +++ b/Ink Canvas/App.xaml.cs @@ -839,7 +839,19 @@ async void App_Startup(object sender, StartupEventArgs e) await Task.Delay(100); RootPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; - LogHelper.NewLog(string.Format("Ink Canvas Starting (Version: {0})", Assembly.GetExecutingAssembly().GetName().Version)); + var version = Assembly.GetExecutingAssembly().GetName().Version; + var informationalVersion = Assembly.GetExecutingAssembly().GetCustomAttribute(); + string versionString = version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision; + if (informationalVersion != null) + { + string infoVersion = informationalVersion.InformationalVersion; + int lastDotIndex = infoVersion.LastIndexOf('.'); + if (lastDotIndex >= 0 && lastDotIndex < infoVersion.Length - 7) + { + versionString += " (" + infoVersion.Substring(lastDotIndex + 1) + ")"; + } + } + LogHelper.NewLog(string.Format("Ink Canvas Starting (Version: {0})", versionString)); // 检查是否为最终应用启动(更新后的应用) bool isFinalApp = e.Args.Contains("--final-app"); diff --git a/Ink Canvas/AssemblyInfo.cs b/Ink Canvas/AssemblyInfo.cs index 67fa9e01..06eaf3b6 100644 --- a/Ink Canvas/AssemblyInfo.cs +++ b/Ink Canvas/AssemblyInfo.cs @@ -3,21 +3,7 @@ using System.Windows; [assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")] -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("InkCanvasForClass")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("CJK_mkp")] -[assembly: AssemblyProduct("InkCanvasForClass")] -[assembly: AssemblyCopyright("Copyright © CJK_mkp 2025-2026")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // i18n: 默认/回退语言为简体中文,与 Strings.resx 默认文案一致。 @@ -44,5 +30,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.18.10")] -[assembly: AssemblyFileVersion("1.7.18.10")] +// [assembly: AssemblyVersion("1.7.18.10")] +// [assembly: AssemblyFileVersion("1.7.18.10")] diff --git a/Ink Canvas/InkCanvasForClass.csproj b/Ink Canvas/InkCanvasForClass.csproj index 5a02ae09..6db6c496 100644 --- a/Ink Canvas/InkCanvasForClass.csproj +++ b/Ink Canvas/InkCanvasForClass.csproj @@ -21,11 +21,9 @@ false false true - 2 - 2.0.2.%2a false false - False + True true true true @@ -67,12 +65,10 @@ app.manifest InkCanvasForClass - 1.7 CJK_mkp InkCanvasForClass © Copyright CJK_mkp 2025-now https://inkcanvasforclass.github.io - bundled False @@ -667,4 +663,12 @@ + + + + <_ShortSha>$(GitCommitIdShort) + <_ShortSha7>$(_ShortSha.Substring(0, 7)) + $(AssemblyVersion).$(_ShortSha7) + + diff --git a/Ink Canvas/Properties/AssemblyInfo.cs b/Ink Canvas/Properties/AssemblyInfo.cs index 89688309..ad34dc32 100644 --- a/Ink Canvas/Properties/AssemblyInfo.cs +++ b/Ink Canvas/Properties/AssemblyInfo.cs @@ -2,46 +2,12 @@ using System.Runtime.InteropServices; using System.Windows; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("InkCanvasForClass")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("CJK_mkp")] -[assembly: AssemblyProduct("InkCanvasForClass")] -[assembly: AssemblyCopyright("Copyright © CJK_mkp 2025-2026")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -// i18n: 默认/回退语言为简体中文,与 Strings.resx 默认文案一致。 [assembly: System.Resources.NeutralResourcesLanguage("zh-CN", System.Resources.UltimateResourceFallbackLocation.MainAssembly)] [assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) + ResourceDictionaryLocation.None, + ResourceDictionaryLocation.SourceAssembly )] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.18.10")] -[assembly: AssemblyFileVersion("1.7.18.10")] diff --git a/Ink Canvas/Windows/SettingsViews/Pages/AboutPage.xaml.cs b/Ink Canvas/Windows/SettingsViews/Pages/AboutPage.xaml.cs index 448755e5..4c1a5e7e 100644 --- a/Ink Canvas/Windows/SettingsViews/Pages/AboutPage.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/Pages/AboutPage.xaml.cs @@ -98,7 +98,18 @@ private void LoadSettings() { try { - AppVersionTextBlock.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + var version = Assembly.GetExecutingAssembly().GetName().Version; + AppVersionTextBlock.Text = version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision; + var informationalVersion = Assembly.GetExecutingAssembly().GetCustomAttribute(); + if (informationalVersion != null) + { + string infoVersion = informationalVersion.InformationalVersion; + int lastDotIndex = infoVersion.LastIndexOf('.'); + if (lastDotIndex >= 0 && lastDotIndex < infoVersion.Length - 7) + { + AppVersionTextBlock.Text += " (" + infoVersion.Substring(lastDotIndex + 1) + ")"; + } + } RefreshDeviceInfo(); } catch (Exception ex) diff --git a/Ink Canvas/Windows/SplashScreen.xaml.cs b/Ink Canvas/Windows/SplashScreen.xaml.cs index fd7b94fd..85cfdc15 100644 --- a/Ink Canvas/Windows/SplashScreen.xaml.cs +++ b/Ink Canvas/Windows/SplashScreen.xaml.cs @@ -257,15 +257,25 @@ private void SetVersionText() if (version != null) { VersionTextBlock.Text = $"v{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; + var informationalVersion = Assembly.GetExecutingAssembly().GetCustomAttribute(); + if (informationalVersion != null) + { + string infoVersion = informationalVersion.InformationalVersion; + int lastDotIndex = infoVersion.LastIndexOf('.'); + if (lastDotIndex >= 0 && lastDotIndex < infoVersion.Length - 7) + { + VersionTextBlock.Text += " (" + infoVersion.Substring(lastDotIndex + 1) + ")"; + } + } } else { - VersionTextBlock.Text = "v5.0.4.0"; + VersionTextBlock.Text = "v1.7.18.10"; } } catch { - VersionTextBlock.Text = "v5.0.4.0"; + VersionTextBlock.Text = "v1.7.18.10"; } } diff --git a/Ink Canvas/packages.lock.json b/Ink Canvas/packages.lock.json index 7369c9f4..8e1ecc4d 100644 --- a/Ink Canvas/packages.lock.json +++ b/Ink Canvas/packages.lock.json @@ -134,6 +134,12 @@ "resolved": "15.0.0", "contentHash": "/KgYw8uvv0Ut8FPvyEa1XJ/TrLSRgvTv3JgC2IT0/8NwoICzbEJWfmfwsE6Dwi8WH0jVkTEO7zRvGvaKqUOhqQ==" }, + "Nerdbank.GitVersioning": { + "type": "Direct", + "requested": "[3.9.50, )", + "resolved": "3.9.50", + "contentHash": "HtOgGF6jZ+WYbXnCUCYPT8Y2d6mIJo9ozjK/FINTRsXdm4Zgv9GehUMa7EFoGQkqrMcDJNOIDwCmENnvXg4UbA==" + }, "Newtonsoft.Json": { "type": "Direct", "requested": "[13.0.4, )", diff --git a/InkCanvas.Controls/InkCanvas.Controls.csproj b/InkCanvas.Controls/InkCanvas.Controls.csproj index 19a6b1ed..ff84bd3a 100644 --- a/InkCanvas.Controls/InkCanvas.Controls.csproj +++ b/InkCanvas.Controls/InkCanvas.Controls.csproj @@ -10,6 +10,7 @@ true 10 CA1416 + false diff --git a/InkCanvas.IACoreHelper/InkCanvas.IACoreHelper.csproj b/InkCanvas.IACoreHelper/InkCanvas.IACoreHelper.csproj index d3e0dc78..72c0de8a 100644 --- a/InkCanvas.IACoreHelper/InkCanvas.IACoreHelper.csproj +++ b/InkCanvas.IACoreHelper/InkCanvas.IACoreHelper.csproj @@ -12,6 +12,7 @@ 512 true true + false x86 diff --git a/InkCanvas.IACoreHelper/Properties/AssemblyInfo.cs b/InkCanvas.IACoreHelper/Properties/AssemblyInfo.cs index 996eff24..d147d643 100644 --- a/InkCanvas.IACoreHelper/Properties/AssemblyInfo.cs +++ b/InkCanvas.IACoreHelper/Properties/AssemblyInfo.cs @@ -7,5 +7,3 @@ [assembly: AssemblyProduct("InkCanvas.IACoreHelper")] [assembly: AssemblyCopyright("Copyright © ICC CE")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/InkCanvas.PluginSdk/InkCanvas.PluginSdk.csproj b/InkCanvas.PluginSdk/InkCanvas.PluginSdk.csproj index 08b660b8..41ee1445 100644 --- a/InkCanvas.PluginSdk/InkCanvas.PluginSdk.csproj +++ b/InkCanvas.PluginSdk/InkCanvas.PluginSdk.csproj @@ -7,6 +7,7 @@ disable Ink_Canvas.Plugins true + false diff --git a/version.json b/version.json new file mode 100644 index 00000000..04f36275 --- /dev/null +++ b/version.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", + "version": "1.7.18.10", + "publicReleaseRefSpec": [ + "^refs/heads/main$", + "^refs/heads/master$", + "^refs/heads/release/.*$" + ], + "nugetPackageVersion": { + "semVer": 2, + "precision": "revision" + }, + "git": { + "shortShaLength": 6, + "getCommitDetails": "always" + }, + "buildNumber": { + "sha": true, + "useAbbreviatedSha": true + }, + "assemblyVersion": { + "precision": "revision" + }, + "npm": { + "precision": "revision" + } +} From 359b5a05fd7386305e76d9719a68d720d2aecc44 Mon Sep 17 00:00:00 2001 From: doudou0720 <98651603+doudou0720@users.noreply.github.com> Date: Sat, 16 May 2026 19:25:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore:=E5=88=A0=E9=99=A4=E5=88=86=E6=94=AF?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [skip ci] Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> --- version.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/version.json b/version.json index 04f36275..3c145ff3 100644 --- a/version.json +++ b/version.json @@ -1,11 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", "version": "1.7.18.10", - "publicReleaseRefSpec": [ - "^refs/heads/main$", - "^refs/heads/master$", - "^refs/heads/release/.*$" - ], "nugetPackageVersion": { "semVer": 2, "precision": "revision"