Hello,
As you may know, the installation process is basically a sequence of actions. Let's have the following example, so you can better understand what I'm about to say:
Action_Deferred_1
Action_Deferred_2
Action_Deferred_3
Basically, the above actions will be executed in the following order: 1, 2 and 3. If one of the action fails, the rollback action will start from bottom to top. For instance, if Action_Deferred_3 fails, the rollback will look like this:
Undo_Action_Deferred_3
Undo_Action_Deferred_2
Undo_Action_Deferred_1
As you can see, the order is reversed. So basically, if you want to have a custom action that executes on rollback stage, when Action_Deferred_3 fails, this could be the order of your actions:
Action_Deferred_1
Action_Deferred_2
Action_Rollback
Action_Deferred_3
The rollback action must be scheduled prior to the failing action.
Please find attached, for your reference, an .AIP file which you can download and build on your machine. This .AIP file contains a PowerShell custom action that returns an exit code of "3", failing the installation. On rollback, there is a message box custom action that will be spawned.
Hope this helps.
Best regards,
Catalin