I have following CustomAction:
<CustomAction Id="ActionName"
After="InstallFinalize">
<![CDATA[NOT Installed AND (VSTORUNTIME4="#1")]]>
</CustomAction>
The problem is that there is a case in CustomAction when I return ActionResult.Failure. In this case installer will show error message and say that installation failed, but application is still partially installed (files are already in Program Files and application shows up in Uninstall programs).
I want that if I return ActionResult.Failure then installation will be aborted and uninstalled. This is what happens if custom action fails in default Visual Studio installer and I think it makes more sense.
Does anybody know how to trigger uninstall if Custom Action failed? Do I need to add something extra to WiX XML?
Currently your custom action is scheduled after the installation transaction was completed (After="InstallFinalize"). The only custom actions that can be rolled back are "deferred" custom actions that are scheduled between "InstallInitialize" and "InstallFinalize". For your deferred custom actions you should also schedule a rollback custom action before it.
Windows Installer supports a transactional story by default with the ability to rollback all changes to the system. The question is, what are you custom actions doing and where/how are they scheduled?
If your CustomActions are changing the state of the machine they need to do so in a transactional manner otherwise the installer can't rollback the out of process changes your code caused.
Here's a couple good reading articles:
Installation Phases and In-Script Execution Options for Custom Actions in Windows Installer
Zataoca: Classes of Custom Actions
Zataoca: Custom actions should be data driven.
Zataoca: Custom actions are (generally) an admission of failure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With