I'm writing an installer file in WiX with a custom action defined in a DLL. The custom action runs on uninstall, and if it fails, I want it to stop the uninstall process and rollback. The action doesn't affect the system, so I am able to call it before InstallInitialize, so it shouldn't have other changes to undo.
I was told that if I defined a property for the custom action, I could then use condition to halt the uninstallation process, as follows:
<SetProperty Id="CA_mine"
Value="No" Sequence="execute"
Before="CA_mine">
Installed AND remove=ALL
</SetProperty>
<CustomAction Id="CA_mine" BinaryKey="BIN_mine" DllEntry="mine" Execute="immediate"/>
<InstallExecuteSequence>
<Custom Action="CA_mine"
Before="InstallInitialize">
Installed AND remove=ALL
</Custom>
</InstallExecuteSequence>
<Condition>
NOT (Installed AND remove=ALL) OR [CA_mine] = "No"
</Condition>
Where mine sets the property CA_mine to be "Yes" if I want the uninstall to stop.
Would this even work? When is the condition tag evaluated? Is there a simpler way to accomplish my goal here (rolling back uninstallation when mine fails)?