Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute Custom Action before RemoveExistingProducts with After="InstallValidate" in WiX

I have something like this:

<InstallExecuteSequence>
  <RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>

Since one of the uninstallation fails i need to execute a Custom Action to solve the problem BEFORE RemoveExistingProducts. Something in the lines of:

<CustomAction Id="FixStuff" .. />

<InstallExecuteSequence>
  <Custom Action="FixStuff" Before="RemoveExistingProducts" />
  <RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>

This of course doesn't work since Custom Action cannot be before InstallInitialize. I'd really like to remove existing products between InstallValidate and InstallInitialize, but i'd like to execute FixStuff before removing existing products.

Is it even possible to do that?

like image 849
Jarmo Pertman Avatar asked Dec 21 '10 16:12

Jarmo Pertman


1 Answers

Unfortunately you cannot run an elevated custom action before RemoveExistingProducts with your current configuration.

Some possible approaches would be:

  1. Move RemoveExistingProducts right before InstallFinalize. This solves the custom action problem, but other problems may occur since this approach has many restrictions (the components need to maintain their names and GUIDs between versions, your custom actions should be aware that the upgrade is performed at installation end etc.).

  2. Create an EXE bootstrapper which fixes the old installer before launching the new MSI. This bootrapper can require Administrator privileges through a manifest:

http://msdn.microsoft.com/en-us/library/bb756929.aspx

  1. Repair the broken MSI by using this method:

    • fix the problem in the old MSI
    • create a BAT or EXE bootstrapper which recaches it through this command:

    msiexec /fv <path_to_msi>

    • distribute this MSI as an update before your new package

When your new package runs RemoveExistingProducts, the old cached MSI should be fixed and it should uninstall correctly.

like image 197
rmrrm Avatar answered Oct 19 '22 10:10

rmrrm