From f7106d30ea057f18ca89097a88ee14f0bd31a1cd Mon Sep 17 00:00:00 2001
From: Yu Leng <42196638+moooyo@users.noreply.github.com>
Date: Fri, 28 Aug 2026 16:32:04 +0800
Subject: [PATCH] Installer: scope DuplicateFiles change to CA cleanup
---
.pipelines/verifyWinUI3DuplicateFiles.ps1 | 9 +--------
.../CustomAction.cpp | 19 ++-----------------
installer/PowerToysSetupVNext/Product.wxs | 7 +++++--
3 files changed, 8 insertions(+), 27 deletions(-)
diff --git a/.pipelines/verifyWinUI3DuplicateFiles.ps1 b/.pipelines/verifyWinUI3DuplicateFiles.ps1
index f2dc781a9c..95c5f4afab 100644
--- a/.pipelines/verifyWinUI3DuplicateFiles.ps1
+++ b/.pipelines/verifyWinUI3DuplicateFiles.ps1
@@ -225,7 +225,7 @@ function Get-WinUI3DuplicateFileData {
throw "Expected $($expectedSourceFiles.Count) WinUI3Apps DuplicateFile rows but found $($winUI3Duplicates.Count) in $resolvedPath."
}
- $customActions = Invoke-MsiQuery $database 'SELECT `Action`, `Type` FROM `CustomAction`' @('Action', 'Type') @('String', 'Integer')
+ $customActions = Invoke-MsiQuery $database 'SELECT `Action` FROM `CustomAction`' @('Action') @('String')
$legacyActions = @('SetCreateWinAppSDKHardlinksParam', 'CreateWinAppSDKHardlinks', 'SetDeleteWinAppSDKHardlinksParam', 'DeleteWinAppSDKHardlinks')
foreach ($legacyAction in $legacyActions) {
if ($customActions.Action -contains $legacyAction) {
@@ -233,11 +233,6 @@ function Get-WinUI3DuplicateFileData {
}
}
- $launchAction = @($customActions | Where-Object { $_.Action -eq 'LaunchPowerToys' })
- if ($launchAction.Count -ne 1 -or ($launchAction[0].Type -band 0x400) -ne 0) {
- throw "LaunchPowerToys must be an immediate custom action in $resolvedPath."
- }
-
if ($fileRows.File -contains 'WinUI3Apps_hardlinks_txt' -or $fileRows.FileName -match '(^|\|)hardlinks\.txt$') {
throw "Legacy hardlinks.txt manifest is still present in $resolvedPath."
}
@@ -256,8 +251,6 @@ function Get-WinUI3DuplicateFileData {
Assert-ActionBefore $sequenceByAction 'UninstallPackageIdentityMSIX' 'RemoveDuplicateFiles' $resolvedPath
Assert-ActionBefore $sequenceByAction 'RemoveDuplicateFiles' 'RemoveFiles' $resolvedPath
Assert-ActionBefore $sequenceByAction 'RemoveDuplicateFiles' 'InstallFiles' $resolvedPath
- Assert-ActionBefore $sequenceByAction 'InstallFinalize' 'LaunchPowerToys' $resolvedPath
-
if ($sequenceByAction.ContainsKey('PatchFiles')) {
Assert-ActionBefore $sequenceByAction 'PatchFiles' 'DuplicateFiles' $resolvedPath
}
diff --git a/installer/PowerToysSetupCustomActionsVNext/CustomAction.cpp b/installer/PowerToysSetupCustomActionsVNext/CustomAction.cpp
index cec7d44640..890a9fdf6e 100644
--- a/installer/PowerToysSetupCustomActionsVNext/CustomAction.cpp
+++ b/installer/PowerToysSetupCustomActionsVNext/CustomAction.cpp
@@ -213,24 +213,11 @@ UINT __stdcall LaunchPowerToysCA(MSIHANDLE hInstall)
UINT er = ERROR_SUCCESS;
std::wstring installationFolder, path, args;
std::wstring commandLine;
- LPWSTR installFolderProperty = nullptr;
- LPWSTR replacedInUseFiles = nullptr;
hr = WcaInitialize(hInstall, "LaunchPowerToys");
ExitOnFailure(hr, "Failed to initialize");
-
- hr = WcaGetProperty(L"ReplacedInUseFiles", &replacedInUseFiles);
- ExitOnFailure(hr, "Failed to get ReplacedInUseFiles property.");
-
- if ((replacedInUseFiles && replacedInUseFiles[0] != L'\0') || MsiGetMode(hInstall, MSIRUNMODE_REBOOTATEND) || MsiGetMode(hInstall, MSIRUNMODE_REBOOTNOW))
- {
- WcaLog(LOGMSG_STANDARD, "LaunchPowerToys: Skipping launch because Windows Installer requires a reboot.");
- goto LExit;
- }
-
- hr = WcaGetProperty(L"INSTALLFOLDER", &installFolderProperty);
- ExitOnFailure(hr, "Failed to get INSTALLFOLDER property.");
- installationFolder = installFolderProperty;
+ hr = getInstallFolder(hInstall, installationFolder);
+ ExitOnFailure(hr, "Failed to get installFolder.");
path = installationFolder;
path += L"\\PowerToys.exe";
@@ -320,8 +307,6 @@ UINT __stdcall LaunchPowerToysCA(MSIHANDLE hInstall)
}
LExit:
- ReleaseStr(installFolderProperty);
- ReleaseStr(replacedInUseFiles);
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}
diff --git a/installer/PowerToysSetupVNext/Product.wxs b/installer/PowerToysSetupVNext/Product.wxs
index b98c2b4dda..48bf6b0741 100644
--- a/installer/PowerToysSetupVNext/Product.wxs
+++ b/installer/PowerToysSetupVNext/Product.wxs
@@ -109,6 +109,7 @@
+
@@ -157,7 +158,7 @@
-
+
@@ -167,12 +168,14 @@
+
+
-
+