Skip to content

Commit f80d3ac

Browse files
authored
Set finalizer's detect condition (#50554)
2 parents 2f8edd9 + edab88b commit f80d3ac

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/Layout/pkg/windows/bundles/sdk/bundle.wxs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,23 +159,22 @@
159159
<Chain DisableSystemRestore="yes" ParallelCache="yes">
160160

161161
<!--
162-
The finalizer is not an installation package. It's detected based on the bundle's installation state (WixBundleInstalled).
163-
164-
User action | Install | Repair | Modify | Uninstall | Uninstall (Upgrade)
165-
WixBundleInstalled | FALSE | TRUE | TRUE | TRUE | TRUE
166-
WixBundleAction | 6 | 8 | 7 | 4 | 4
167-
Finalizer (Plan) | None | Execute | Execute | Execute | Execute
168-
169-
Setting an InstallCondition will cause Burn to remove the package if it evaluates to FALSE and
170-
the bundle is being installed, repaired, or modified. This breaks upgrades. We cannot use
171-
WixBundleAction in the DetectCondition because it's not finalized until the planning phase completes (after
172-
the detect phase). See https://github.com/orgs/wixtoolset/discussions/9017 for more detail.
173-
174-
The finalizer also takes the bundle action as a parameter to ensure it no-ops, but logs the action. -->
162+
The finalizer is not an installation package (ExePackage@Bundle="no"). For an install, the finalizer has no
163+
effect, but must be detected as absent. When an install is cancelled, the engine re-eavaluates package state. If
164+
a package is detected as present the resume mode is set to BURN_RESUME_MODE_ARP and causes the bundle registration
165+
to remain. When the bundle is removed, it finalizer must be detected as installed to ensure it executes.
166+
167+
Setting the detect condition to WixBundleInstalled causes the finalzier state to track the bundle state. This causes
168+
the finalizer to run during install, repair and uninstall actions. We can't use WixBundleAction in
169+
ExePackage@DetectCondition because it's value is only final after planning completes after the detect phase.
170+
See https://github.com/orgs/wixtoolset/discussions/9017 for more detail.
171+
172+
Instead, we pass WixBundleAction to the finalizer as parameter when the package is applied. This allows the finalizer
173+
to no-op during an install and repair, but clean up when the bundle is being remvoed. -->
175174
<ExePackage SourceFile="$(FinalizerExeSourceFile)"
176175
Bundle="no"
177176
Cache="keep"
178-
DetectCondition="1=1"
177+
DetectCondition="WixBundleInstalled"
179178
Id="Finalizer"
180179
InstallArguments="&quot;[WixBundleLog_Finalizer]&quot; $(Version) $(TargetArchitecture) [WixBundleAction]"
181180
UninstallArguments="&quot;[WixBundleLog_Finalizer]&quot; $(Version) $(TargetArchitecture) [WixBundleAction]"

0 commit comments

Comments
 (0)