[wix-users] Repair Rollback for Custom Actions

Edwin Castro egcastr at gmail.com
Wed May 16 14:57:13 PDT 2018


Suppose I have a set of custom actions functions to install and uninstall a
resource:

InstallResource
UninstallResource

Suppose I have used those custom action functions as follows:

<CustomAction Id="UninstallResourceRollback"
              DllEntry="InstallResource"
              Execute="rollback" .../>
<CustomAction Id="UninstallResourceExecute"
              DllEntry="UninstallResource"
              Execute="deferred" .../>
<CustomAction Id="InstallResourceRollback"
              DllEntry="UninstallResource"
              Execute="rollback" .../>
<CustomAction Id="InstallResourceExecute"
              DllEntry="InstallResource"
              Execute="deferred" .../>

Suppose these custom actions are scheduled as follows:

<InstallExecuteSequence>
  <Custom Action="UninstallResourceRollback"
          Before="UninstallResourceExecute">
    <!-- Action state for ComponentId is Absent -->
    <![CDATA[$ComponentId = 2]]>
  </Custom>
  <Custom Action="UninstallResourceExecute"
          Before="...">
    <!-- Action state for ComponentId is Absent -->
    <![CDATA[$ComponentId = 2]]>
  </Custom>
  <Custom Action="InstallResourceRollback"
          After="...">
    <!-- Action state for ComponentId is Local -->
    <![CDATA[$ComponentId = 3]]>
  </Custom>
  <Custom Action="InstallResourceExecute"
          After="InstallResourceRollback">
    <!-- Action state for ComponentId is Local -->
    <![CDATA[$ComponentId = 3]]>
  </Custom>
</InstallExecuteSequence>

This setup gets me correct behavior for install, install rollback,
uninstall, uninstall rollback, upgrade, and upgrade rollback.

I just discovered that this setup does not work well for reinstall
rollback. If reinstall succeeds, then everything is great! But if
InstallResourceExecute fails during reinstall, then InstallResourceRollback
uninstalls the resource which is *NOT* what I want.

I considered checking the component installed state for
InstallResourceRollback like so:

<InstallExecuteSequence>
  <Custom Action="InstallResourceRollback"
          After="...">
    <!-- Installed state for Component Id is Absent
         AND
         Action state for ComponentId is Local -->
    <![CDATA[?ComponentId = 2 AND $ComponentId = 3]]>
  </Custom>
</InstallExecuteSequence>

but I wonder if I should try to install the resource again during rollback.

Am I missing anything important here? Should I only change the condition
for InstallResourceRollback? Or should I also include an
InstallResourceRepairRollback with DllEntry="InstallResource"? Is there
another option I'm not considering?

--
Edwin G. Castro


More information about the wix-users mailing list