From 5cc30df4db08094145610d63835ddab2038d6c36 Mon Sep 17 00:00:00 2001 From: moooyo <42196638+moooyo@users.noreply.github.com> Date: Tue, 25 Feb 2025 02:56:04 +0800 Subject: [PATCH] [AOT] Clean up AOT build issue in Common.UI (#36376) * init commit * Use path.combine * Add useWPF and useWindowsForms back --------- Co-authored-by: Yu Leng (from Dev Box) --- src/common/Common.UI/Common.UI.csproj | 1 + src/common/Common.UI/SettingsDeepLink.cs | 10 +++++----- src/common/Common.UI/ThemeManager.cs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/common/Common.UI/Common.UI.csproj b/src/common/Common.UI/Common.UI.csproj index 8d19debc3b43..19fe2f1ee4d2 100644 --- a/src/common/Common.UI/Common.UI.csproj +++ b/src/common/Common.UI/Common.UI.csproj @@ -1,6 +1,7 @@  + true diff --git a/src/common/Common.UI/SettingsDeepLink.cs b/src/common/Common.UI/SettingsDeepLink.cs index 584d9decf67f..bb26fa71e683 100644 --- a/src/common/Common.UI/SettingsDeepLink.cs +++ b/src/common/Common.UI/SettingsDeepLink.cs @@ -91,20 +91,20 @@ public static void OpenSettings(SettingsWindow window, bool mainExecutableIsOnTh { try { - var assemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - var fullPath = new DirectoryInfo(assemblyPath).FullName; + var directoryPath = System.AppContext.BaseDirectory; if (mainExecutableIsOnTheParentFolder) { // Need to go into parent folder for PowerToys.exe. Likely a WinUI3 App SDK application. - fullPath = fullPath + "\\..\\PowerToys.exe"; + directoryPath = Path.Combine(directoryPath, ".."); + directoryPath = Path.Combine(directoryPath, "PowerToys.exe"); } else { // PowerToys.exe is in the same path as the application. - fullPath = fullPath + "\\PowerToys.exe"; + directoryPath = Path.Combine(directoryPath, "PowerToys.exe"); } - Process.Start(new ProcessStartInfo(fullPath) { Arguments = "--open-settings=" + SettingsWindowNameToString(window) }); + Process.Start(new ProcessStartInfo(directoryPath) { Arguments = "--open-settings=" + SettingsWindowNameToString(window) }); } catch { diff --git a/src/common/Common.UI/ThemeManager.cs b/src/common/Common.UI/ThemeManager.cs index d30084ef6ec5..fe6e02ad9446 100644 --- a/src/common/Common.UI/ThemeManager.cs +++ b/src/common/Common.UI/ThemeManager.cs @@ -11,7 +11,7 @@ namespace Common.UI { - public class ThemeManager : IDisposable + public partial class ThemeManager : IDisposable { private readonly Application _app; private const string LightTheme = "Light.Accent1";