The Setup
So I have a Custom Action that is marked as Deferred and executes Before InstallFinalize. It looks like this:
<CustomAction Id="CADeferred"
BinaryKey="binaryCustomActions"
DllEntry="CADeferredMethod"
Execute="deferred"/>
<InstallExecuteSequence>
...
<Custom Action="CADeferred"
Before='InstallFinalize'>Not Installed or Upgrading</Custom>
</InstallExecuteSequence>
And I have Version 1.0 installed currently on the computer environment & fully functional. I then use the Version 2.0 MSI to do an Upgrade.
The Issue I'm Running Into
When doing the Upgrade, that Custom Action can fail and returns ActionResult.Failure
. When that happens, the installer fails and says:
"Product Setup Wizard ended prematurely because of an error. Your system has not been modified. To install this program at a later time, run Setup Wizard again. Click the Finish button to exit the Setup Wizard."
Once I click Finish. I checked that the product itself has been removed completely from the computer environment. Like it has been uninstalled essentially.
I was hoping it would Rollback to the Version 1.0 as it was before the Upgrade.
What I'm Trying To Accomplish
If this scenario happens, I like the installer to Rollback to Version 1.0 on the environment.
What I've Done So Far
I've researched on Google for more information on how InstallFinalize works, how Rollbacks work, etc.
From my research, having a Deferred Custom Action to run Before InstallFinalize is the way to go for a Custom Action that needs to modify state on the environment. As well as being able to use the new files on the new installer such as a DLL because it runs "inside" the InstallFinalize step. Since it's defined Before InstallFinalize I thought the Rollback of it would put the system back to the previous installed version of the product.
I've tried making it into a Immediate Custom Action to run After InstallFinalize, but that's bad. If it fails, the product still Upgraded to Version 2.0. Which is odd. Plus I know this is frown upon. So I went to Deferred Custom Action to run Before InstallFinalize.
I also read that usually Deferred Custom Actions have a Rollback Custom Action associated with it. However, due the functionality of the Deferred Custom Action, we can't necessarily fix the issue with a Rollback Custom Action. Reason is because it takes an admin to really check out the failure and manually do any changes needed for a retry of the Upgrade to work the next time. So hence we don't include an associate Rollback Custom Action.
So I'm pretty stumped at this point. Any help or direction would be very much appreciated. If I'm not being clear enough, feel free to ask for more clarification. Please and thank you.