From 0783763dd080baa43f2736acaabe35550ecde9d9 Mon Sep 17 00:00:00 2001 From: Yu Leng <42196638+moooyo@users.noreply.github.com> Date: Tue, 15 Jul 2025 22:15:18 +0800 Subject: [PATCH] [AOT] Enable AOT for CmdPal (#40551) ## Summary of the Pull Request Base on https://github.com/microsoft/PowerToys/pull/40486 we can easily use lab package. So all blocker has been resolved. 1. Replace CommunityToolkit.WinUI.UI.Controls.Markdown with CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock 2. Add default markdown style config to align some configuration with the original one. (but still have some gap) 3. Add new configuration in pipeline to control the AOT enable/disable. ## PR Checklist - [x] **Closes:** #38279 - [x] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [x] **Tests:** Added/updated and all pass - [x] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --------- Co-authored-by: Yu Leng (from Dev Box) Co-authored-by: Mike Griese --- .github/actions/spell-check/expect.txt | 1 + .pipelines/v2/release.yml | 7 +++++- .pipelines/verifyDepsJsonLibraryVersions.ps1 | 2 +- Directory.Packages.props | 1 + NOTICE.md | 2 +- src/Common.Dotnet.AotCompatibility.props | 3 ++- .../ShortcutDialogContentControl.xaml | 4 ++-- .../ShortcutWithTextLabelControl.xaml | 4 ++-- .../ExtViews/ContentPage.xaml | 22 ++++++++++--------- .../Microsoft.CmdPal.UI.csproj | 10 ++++++++- .../Microsoft.CmdPal.UI/NativeMethods.txt | 1 - .../Microsoft.CmdPal.UI/Pages/ShellPage.xaml | 16 +++++++++----- .../PublishProfiles/win-arm64.pubxml | 4 ++-- .../Properties/PublishProfiles/win-x64.pubxml | 4 ++-- 14 files changed, 51 insertions(+), 30 deletions(-) diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index cd6e9b0a2b..3d22a06313 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -1383,6 +1383,7 @@ RIGHTSCROLLBAR riid RKey RNumber +Rns rop ROUNDSMALL ROWSETEXT diff --git a/.pipelines/v2/release.yml b/.pipelines/v2/release.yml index 227dd1cf71..18163e899a 100644 --- a/.pipelines/v2/release.yml +++ b/.pipelines/v2/release.yml @@ -38,6 +38,11 @@ parameters: displayName: "Build Using Visual Studio Preview" default: false + - name: enableAOT + type: boolean + displayName: "Enable AOT (Ahead-of-Time) Compilation for CmdPal" + default: true + name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr) variables: @@ -95,7 +100,7 @@ extends: useManagedIdentity: $(SigningUseManagedIdentity) clientId: $(SigningOriginalClientId) # Have msbuild use the release nuget config profile - additionalBuildOptions: /p:RestoreConfigFile="$(Build.SourcesDirectory)\.pipelines\release-nuget.config" + additionalBuildOptions: /p:RestoreConfigFile="$(Build.SourcesDirectory)\.pipelines\release-nuget.config" /p:EnableCmdPalAOT=${{ parameters.enableAOT }} beforeBuildSteps: # Sets versions for all PowerToy created DLLs - pwsh: |- diff --git a/.pipelines/verifyDepsJsonLibraryVersions.ps1 b/.pipelines/verifyDepsJsonLibraryVersions.ps1 index 085e1e439a..6123316b5f 100644 --- a/.pipelines/verifyDepsJsonLibraryVersions.ps1 +++ b/.pipelines/verifyDepsJsonLibraryVersions.ps1 @@ -19,7 +19,7 @@ Get-ChildItem $targetDir -Recurse -Filter *.deps.json -Exclude *UITest*,MouseJum # Temporarily exclude All UI-Test, Fuzzer-Test projects because of Appium.WebDriver dependencies $depsJsonFullFileName = $_.FullName - if ($depsJsonFullFileName -like "*CmdPal*") { + if ($depsJsonFullFileName -like "*CmdPal*" -or $depsJsonFullFileName -like "*CommandPalette*") { return } diff --git a/Directory.Packages.props b/Directory.Packages.props index 5ebced2715..f29669d9e7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -21,6 +21,7 @@ + diff --git a/NOTICE.md b/NOTICE.md index 2b1201bc50..b2232e4984 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -1497,6 +1497,7 @@ SOFTWARE. - Appium.WebDriver 4.4.5 - Azure.AI.OpenAI 1.0.0-beta.17 - CommunityToolkit.Common 8.4.0 +- CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock 0.1.250703-build.2173 - CommunityToolkit.Mvvm 8.4.0 - CommunityToolkit.WinUI.Animations 8.2.250402 - CommunityToolkit.WinUI.Collections 8.2.250402 @@ -1579,4 +1580,3 @@ SOFTWARE. - WinUIEx 2.2.0 - WPF-UI 3.0.5 - WyHash 1.0.5 - diff --git a/src/Common.Dotnet.AotCompatibility.props b/src/Common.Dotnet.AotCompatibility.props index 82988104dd..bebb88428c 100644 --- a/src/Common.Dotnet.AotCompatibility.props +++ b/src/Common.Dotnet.AotCompatibility.props @@ -7,6 +7,7 @@ 2 - IL2081;CsWinRT1028;$(WarningsNotAsErrors) + + IL2081;CsWinRT1028;CA1416;$(WarningsNotAsErrors) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/ShortcutDialogContentControl.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/ShortcutDialogContentControl.xaml index 7932a27e91..56ae0bfca6 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/ShortcutDialogContentControl.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/ShortcutDialogContentControl.xaml @@ -4,8 +4,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="using:Microsoft.CmdPal.UI.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:labToolkit="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:tk7controls="using:CommunityToolkit.WinUI.UI.Controls" x:Name="ShortcutContentControl" mc:Ignorable="d"> @@ -66,7 +66,7 @@ IsTabStop="{Binding ElementName=ShortcutContentControl, Path=IsWarningAltGr, Mode=OneWay}" Severity="Warning" /> - @@ -36,7 +36,7 @@ - + + + - @@ -61,12 +66,9 @@ - diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj index 75e49fd695..44ef3483e2 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj @@ -1,5 +1,6 @@  + @@ -23,6 +24,13 @@ false + + true + false + false + true + + true @@ -71,7 +79,7 @@ - + diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt index 165933fe93..a432d9a808 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt @@ -22,7 +22,6 @@ SetActiveWindow MonitorFromWindow GetMonitorInfo GetDpiForMonitor -CoAllowSetForegroundWindow WM_HOTKEY WM_NCLBUTTONDBLCLK diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml index 63877834e9..9df81e1513 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml @@ -9,8 +9,10 @@ xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:help="using:Microsoft.CmdPal.UI.Helpers" + xmlns:labToolkit="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock" + xmlns:markdownTextBlockRns="using:CommunityToolkit.WinUI.Controls.MarkdownTextBlockRns" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls" + xmlns:toolkit="using:CommunityToolkit.WinUI.Controls" xmlns:ui="using:CommunityToolkit.WinUI" xmlns:viewModels="using:Microsoft.CmdPal.UI.ViewModels" Background="Transparent" @@ -144,6 +146,11 @@ + + @@ -406,14 +413,11 @@ TextWrapping="WrapWholeWords" Visibility="{x:Bind ViewModel.Details.Title, Converter={StaticResource StringNotEmptyToVisibilityConverter}, Mode=OneWay}" /> - False False True - False - False + True + False \ No newline at end of file diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-x64.pubxml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-x64.pubxml index 5ff16b291b..7f6d14d1ad 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-x64.pubxml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Properties/PublishProfiles/win-x64.pubxml @@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. False False True - False - False + True + False \ No newline at end of file