XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

HaloPixelToolBox

【WinUI3】基于USB HID通讯的花再音响工具箱

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/HaloPixelToolBox

重命名应用标识并加入迁移与发布调整

将应用标识从 HaloPixelToolBox.Client 统一迁移为 HaloPixelToolBox(AssemblyName、RootNamespace、XAML Title、manifest 显示名等);在 App 构造中调用 ApplicationIdentityMigration.Run(),新增 ApplicationIdentityMigration 用于迁移旧 LocalAppData 目录与注册表自启项并删除旧自启键,确保旧用户数据与自启设置平滑过渡。 引入 SystemProfile 常量(ApplicationName、ApplicationExecutableName、LegacyApplicationName),并调整 InstallPath 默认值;在 Installer 端统一使用 SystemProfile.ApplicationName 并增加对旧客户端残留的清理(CleanupLegacyClientArtifacts),InstallProgressPage 新增 CreateApplicationShortcut(),改用 using(File.OpenRead) 并改进异常与文件存在检查、路径规范化与安全判断。 调整升级启动逻辑:UpgradeHelper.StartUpdate 以安装器位于 AppContext.BaseDirectory 为启动路径并传递安装目录参数;安装流程中将创建快捷方式逻辑抽成方法并改进健壮性。 修改 SettingPageViewModel 中自动启动注册默认名称为 HaloPixelToolBox;修正若干 XAML 布局与窗口标题小改动;多个项目的 PublishProfile 从 win-$(Platform).pubxml 切换/新增为 FolderProfile.pubxml,新增相应 pubxml 文件并在 HaloPixelToolBox.Installer.csproj 引用,同时移除不必要包;更新 .gitignore 发布配置规则。 总体目标:把发布产物与运行时标识统一为 HaloPixelToolBox,保证升级/安装时的数据、自启与快捷方式不丢失或重复,并简化发布流程。

5bd2eb8
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

17 个文件 +175 -26
Modified .gitignore +4 -0
@@ -364,3 +364,7 @@ FodyWeavers.xsd
364 364 /HaloPixelToolBox.Installer.Package/Source.zip
365 365 /HaloPixelToolBox.Installer/Resources/Resource/Source.zip
366 366 /Client/HaloPixelToolBox.Installer/Resources/Resource/Source.zip
367
368 # Shared, credential-free publish profiles used by the client packaging workflow.
369 !Client/HaloPixelToolBox.Client/Properties/PublishProfiles/FolderProfile.pubxml
370 !Client/HaloPixelToolBox.Installer/Properties/PublishProfiles/FolderProfile.pubxml
Modified Client/HaloPixelToolBox.Client/App.xaml.cs +1 -0
@@ -29,6 +29,7 @@ public partial class App : Application
29 29 /// </summary>
30 30 public App()
31 31 {
32 ApplicationIdentityMigration.Run();
32 33 var keyInstance = AppInstance.FindOrRegisterForKey("MainInstance");
33 34 if (!keyInstance.IsCurrent)
34 35 {
Modified Client/HaloPixelToolBox.Client/HaloPixelToolBox.Client.csproj +3 -1
@@ -1,12 +1,14 @@
1 1 <Project Sdk="Microsoft.NET.Sdk">
2 2 <PropertyGroup>
3 3 <OutputType>WinExe</OutputType>
4 <AssemblyName>HaloPixelToolBox</AssemblyName>
5 <RootNamespace>HaloPixelToolBox.Client</RootNamespace>
4 6 <TargetFramework>net10.0-windows10.0.22621.0</TargetFramework>
5 7 <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
6 8 <ApplicationManifest>app.manifest</ApplicationManifest>
7 9 <Platforms>x86;x64;ARM64</Platforms>
8 10 <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
9 <PublishProfile>win-$(Platform).pubxml</PublishProfile>
11 <PublishProfile>FolderProfile.pubxml</PublishProfile>
10 12 <UseWinUI>true</UseWinUI>
11 13 <Version>1.3.0</Version>
12 14 <EnableMsixTooling>true</EnableMsixTooling>
Modified Client/HaloPixelToolBox.Client/MainWindow.xaml +1 -1
@@ -7,7 +7,7 @@
7 7 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8 8 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9 9 mc:Ignorable="d"
10 Title="HaloPixelToolBox.Client">
10 Title="HaloPixelToolBox">
11 11 <Window.SystemBackdrop>
12 12 <MicaBackdrop />
13 13 </Window.SystemBackdrop>
Modified Client/HaloPixelToolBox.Client/Package.appxmanifest +3 -3
@@ -15,7 +15,7 @@
15 15 <mp:PhoneIdentity PhoneProductId="449a555a-b6b8-44b1-9b17-592898649b32" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
16 16
17 17 <Properties>
18 <DisplayName>XFEApplication</DisplayName>
18 <DisplayName>HaloPixelToolBox</DisplayName>
19 19 <PublisherDisplayName>XFEstudio</PublisherDisplayName>
20 20 <Logo>Assets\StoreLogo.png</Logo>
21 21 </Properties>
@@ -34,8 +34,8 @@
34 34 Executable="$targetnametoken$.exe"
35 35 EntryPoint="$targetentrypoint$">
36 36 <uap:VisualElements
37 DisplayName="$ext_specifiedsolutionname$"
38 Description="$ext_specifiedsolutionname$"
37 DisplayName="HaloPixelToolBox"
38 Description="HaloPixelToolBox"
39 39 BackgroundColor="transparent"
40 40 Square150x150Logo="Assets\Square150x150Logo.png"
41 41 Square44x44Logo="Assets\Square44x44Logo.png">
Added Client/HaloPixelToolBox.Client/Properties/PublishProfiles/FolderProfile.pubxml +17 -0
@@ -0,0 +1,17 @@
1 <?xml version="1.0" encoding="utf-8"?>
2 <!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
3 <Project>
4 <PropertyGroup>
5 <Configuration>Release</Configuration>
6 <Platform>x64</Platform>
7 <PublishDir>bin\win-x64\Release\net10.0-windows10.0.22621.0\publish\</PublishDir>
8 <PublishProtocol>FileSystem</PublishProtocol>
9 <_TargetId>Folder</_TargetId>
10 <TargetFramework>net10.0-windows10.0.22621.0</TargetFramework>
11 <RuntimeIdentifier>win-x64</RuntimeIdentifier>
12 <SelfContained>true</SelfContained>
13 <PublishSingleFile>false</PublishSingleFile>
14 <PublishReadyToRun>true</PublishReadyToRun>
15 <PublishTrimmed>false</PublishTrimmed>
16 </PropertyGroup>
17 </Project>
Added Client/HaloPixelToolBox.Client/Utilities/ApplicationIdentityMigration.cs +76 -0
@@ -0,0 +1,76 @@
1 using System.Diagnostics;
2 using Microsoft.Win32;
3
4 namespace HaloPixelToolBox.Client.Utilities;
5
6 /// <summary>
7 /// 在发布产物由 HaloPixelToolBox.Client 更名后保留用户数据和自启动配置。
8 /// </summary>
9 public static class ApplicationIdentityMigration
10 {
11 private const string ApplicationName = "HaloPixelToolBox";
12 private const string LegacyApplicationName = "HaloPixelToolBox.Client";
13
14 public static void Run()
15 {
16 CopyLegacyAppData();
17 MigrateAutoStartRegistration();
18 }
19
20 private static void CopyLegacyAppData()
21 {
22 try
23 {
24 var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
25 var legacyRoot = Path.GetFullPath(Path.Combine(localAppData, LegacyApplicationName));
26 var currentRoot = Path.GetFullPath(Path.Combine(localAppData, ApplicationName));
27 if (!Directory.Exists(legacyRoot) || string.Equals(legacyRoot, currentRoot, StringComparison.OrdinalIgnoreCase))
28 return;
29
30 Directory.CreateDirectory(currentRoot);
31 foreach (var sourcePath in Directory.EnumerateFiles(legacyRoot, "*", SearchOption.AllDirectories))
32 {
33 try
34 {
35 var relativePath = Path.GetRelativePath(legacyRoot, sourcePath);
36 var destinationPath = Path.GetFullPath(Path.Combine(currentRoot, relativePath));
37 if (!destinationPath.StartsWith(currentRoot + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) ||
38 File.Exists(destinationPath))
39 continue;
40
41 var destinationDirectory = Path.GetDirectoryName(destinationPath);
42 if (!string.IsNullOrEmpty(destinationDirectory))
43 Directory.CreateDirectory(destinationDirectory);
44 File.Copy(sourcePath, destinationPath);
45 }
46 catch (Exception ex)
47 {
48 Debug.WriteLine($"无法迁移旧应用数据文件 {sourcePath}:{ex.Message}");
49 }
50 }
51 }
52 catch (Exception ex)
53 {
54 Debug.WriteLine($"无法迁移旧应用数据:{ex.Message}");
55 }
56 }
57
58 private static void MigrateAutoStartRegistration()
59 {
60 try
61 {
62 const string runKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";
63 using var key = Registry.CurrentUser.OpenSubKey(runKey, true);
64 if (key?.GetValue(LegacyApplicationName) is null)
65 return;
66
67 if (key.GetValue(ApplicationName) is null && !string.IsNullOrWhiteSpace(Environment.ProcessPath))
68 key.SetValue(ApplicationName, $"\"{Environment.ProcessPath}\"");
69 key.DeleteValue(LegacyApplicationName, false);
70 }
71 catch (Exception ex)
72 {
73 Debug.WriteLine($"无法迁移旧自启动配置:{ex.Message}");
74 }
75 }
76 }
Modified Client/HaloPixelToolBox.Client/Utilities/Helpers/UpgradeHelper.cs +4 -3
@@ -52,16 +52,17 @@ public static class UpgradeHelper
52 52 /// </summary>
53 53 public static void StartUpdate(string downloadUrl)
54 54 {
55 var startInfo = new ProcessStartInfo("Installer.exe")
55 var installDirectory = AppContext.BaseDirectory;
56 var startInfo = new ProcessStartInfo(Path.Combine(installDirectory, "Installer.exe"))
56 57 {
57 58 UseShellExecute = true,
58 59 Verb = "runas"
59 60 };
60 61 startInfo.ArgumentList.Add("Upgrade");
61 62 startInfo.ArgumentList.Add(downloadUrl);
62 startInfo.ArgumentList.Add("");
63 startInfo.ArgumentList.Add(installDirectory);
63 64 Process.Start(startInfo);
64 65 Process.GetCurrentProcess().Kill();
65 66 Application.Current.Exit();
66 67 }
67 }
68 }
Modified Client/HaloPixelToolBox.Client/ViewModels/SettingPageViewModel.cs +1 -1
@@ -53,7 +53,7 @@ public partial class SettingPageViewModel : ViewModelBase
53 53
54 54 partial void OnMinimizeWhenOpenChanged(bool value) => SystemProfile.MinimizeWhenOpen = value;
55 55
56 private static void SetAutoStart(bool enable) => SetAutoStart(enable, Assembly.GetExecutingAssembly().GetName().Name ?? "HaloPixelToolBox.Client");
56 private static void SetAutoStart(bool enable) => SetAutoStart(enable, Assembly.GetExecutingAssembly().GetName().Name ?? "HaloPixelToolBox");
57 57
58 58 private static void SetAutoStart(bool enable, string appName, string exePath = "")
59 59 {
Modified Client/HaloPixelToolBox.Client/app.manifest +2 -2
@@ -1,6 +1,6 @@
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3 <assemblyIdentity version="1.0.0.0" name="XFEApplication.app"/>
3 <assemblyIdentity version="1.0.0.0" name="HaloPixelToolBox.app"/>
4 4
5 5 <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
6 6 <application>
@@ -16,4 +16,4 @@
16 16 <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
17 17 </windowsSettings>
18 18 </application>
19 </assembly>
19 </assembly>
Modified Client/HaloPixelToolBox.Installer/HaloPixelToolBox.Installer.csproj +1 -1
@@ -6,6 +6,7 @@
6 6 <Nullable>enable</Nullable>
7 7 <ImplicitUsings>enable</ImplicitUsings>
8 8 <UseWPF>true</UseWPF>
9 <PublishProfile>FolderProfile.pubxml</PublishProfile>
9 10 <ApplicationManifest>app.manifest</ApplicationManifest>
10 11 <ApplicationIcon>Resources\Icon\Icon.ico</ApplicationIcon>
11 12 <AssemblyName>Installer</AssemblyName>
@@ -51,7 +52,6 @@
51 52
52 53 <ItemGroup>
53 54 <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.2" />
54 <PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
55 55 <PackageReference Include="XFEExtension.NetCore" Version="4.2.4" />
56 56 <PackageReference Include="XFEExtension.NetCore.InputSimulator" Version="2.3.0" />
57 57 </ItemGroup>
Modified Client/HaloPixelToolBox.Installer/Profiles/SystemProfile.cs +8 -2
@@ -2,6 +2,10 @@
2 2
3 3 public class SystemProfile
4 4 {
5 public const string ApplicationName = "HaloPixelToolBox";
6 public const string ApplicationExecutableName = ApplicationName + ".exe";
7 public const string LegacyApplicationName = "HaloPixelToolBox.Client";
8
5 9 /// <summary>
6 10 /// 当前窗口DPI缩放
7 11 /// </summary>
@@ -29,9 +33,11 @@ public class SystemProfile
29 33 /// <summary>
30 34 /// 安装目录
31 35 /// </summary>
32 public static string InstallPath { get; set; } = @$"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}\HaloPixelToolBox.Client";
36 public static string InstallPath { get; set; } = System.IO.Path.Combine(
37 Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
38 ApplicationName);
33 39 /// <summary>
34 40 /// 第一次安装
35 41 /// </summary>
36 42 public static bool FirstInstall { get; set; } = false;
37 }
43 }
Added Client/HaloPixelToolBox.Installer/Properties/PublishProfiles/FolderProfile.pubxml +16 -0
Modified Client/HaloPixelToolBox.Installer/ViewModel/Pages/InstallPageViewModel.cs +5 -3
Modified Client/HaloPixelToolBox.Installer/ViewModel/Pages/InstallProgressPageViewModel.cs +2 -2
Modified Client/HaloPixelToolBox.Installer/Views/Pages/InstallProgressPage.xaml.cs +30 -4
Modified Client/HaloPixelToolBox.Installer/Views/Pages/Popups/AgreementDialogPopupPage.xaml +1 -3