Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip custom action on uninstall (WiX)

I'm authoring a MSI for an existing product. In the previous version there was a custom action that wasn't restricted to only run on install, and now fails on uninstall w/ MajorUpgrade.

Is there any way in the new installer, to tell WiX to skip over that particular custom action on uninstall?

like image 657
Lykathia Avatar asked Oct 17 '22 10:10

Lykathia


1 Answers

Yes, you can do this automatically from the new installer.

The solution:

1) You need to fix the problem in the project that builds your current version of the installer and build the good MSI again, from that project. In this case you only need the MSI database, which normally is a few KB, not the entire setup package (i.e CAB files containing all the installation files, etc...)

2) In the new installer, you need a custom action that runs before RemoveExistingProducts standard action which will recache the MSI for the previous version on the machine. Your custom action must execute this command:

msiexec.exe /fv "< path_to_MSI >"

The MSI you're trying to recache the is the new one you'be built in step #1. You need to include this MSI as a resource in the new version installer (and future versions, in case some users skip this version), and pass to you custom action the full path, where this MSI file is extracted, as a parameter.

Basically what you are doing to is automate the steps of recaching the old installation with a correct MSI (where you have set the correct conditions on your custom action). Now, when the RemoveExistingProducts standard action will execute, Windows Installer will trigger the uninstall of the old version using the newly cached MSI, which has the correct conditions set on your custom action, and uninstall successfully.

like image 132
Bogdan Mitrache Avatar answered Oct 21 '22 05:10

Bogdan Mitrache