From 883c98f4492ed9fa9d91e91c47de88f659badaba Mon Sep 17 00:00:00 2001 From: Kai Tao <69313318+vanzue@users.noreply.github.com> Date: Fri, 23 Jan 2026 09:58:53 +0800 Subject: [PATCH] Cmdpal: use latest msix to install (#44886) ## Summary of the Pull Request We should install latest cmdpal msix ## PR Checklist - [ ] Closes: #44860 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **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 --- installer/PowerToysSetupVNext/CmdPal.wxs | 1 + src/common/utils/package.h | 25 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/installer/PowerToysSetupVNext/CmdPal.wxs b/installer/PowerToysSetupVNext/CmdPal.wxs index f05a1f2f35..b6b80127c2 100644 --- a/installer/PowerToysSetupVNext/CmdPal.wxs +++ b/installer/PowerToysSetupVNext/CmdPal.wxs @@ -18,6 +18,7 @@ + diff --git a/src/common/utils/package.h b/src/common/utils/package.h index 138f3b8e5b..58961f93ac 100644 --- a/src/common/utils/package.h +++ b/src/common/utils/package.h @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -337,6 +338,30 @@ namespace package } } } + + // Sort by package version in descending order (newest first) + std::sort(matchedFiles.begin(), matchedFiles.end(), [](const std::wstring& a, const std::wstring& b) { + std::wstring nameA, nameB; + PACKAGE_VERSION versionA{}, versionB{}; + + bool gotA = GetPackageNameAndVersionFromAppx(a, nameA, versionA); + bool gotB = GetPackageNameAndVersionFromAppx(b, nameB, versionB); + + // Files that failed to parse go to the end + if (!gotA) + return false; + if (!gotB) + return true; + + // Compare versions: Major, Minor, Build, Revision (descending) + if (versionA.Major != versionB.Major) + return versionA.Major > versionB.Major; + if (versionA.Minor != versionB.Minor) + return versionA.Minor > versionB.Minor; + if (versionA.Build != versionB.Build) + return versionA.Build > versionB.Build; + return versionA.Revision > versionB.Revision; + }); } catch (const std::exception& ex) {