0

I am trying to run a custom action before my application gets upgraded or uninstalled ( Before the files are removed as I have to copy a database file to another directory )

Problem - I am able to run it when I uninstall it from control panel but I am unable to do so when I Upgrade it.On upgrading the setup is getting ended prematurely and the old version is also getting removed.

Here is my code -

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."/>

<Binary Id="secondAction" SourceFile="..\Migrations\bin\Debug\Migrations.CA.dll" />

<CustomAction Id="secondActionId"
              BinaryKey="secondAction"
              DllEntry="Migrate"
              Execute="deferred"
              Return="check" />

<InstallExecuteSequence>
   <Custom Action="secondActionId" Before ="RemoveFiles">(REMOVE~="ALL") OR (WIX_UPGRADE_DETECTED)</Custom>
</InstallExecuteSequence>

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
AP7
  • 45
  • 1
  • 7
  • 1
    Have a look at this thread https://stackoverflow.com/questions/18531272/how-do-i-distinguish-between-a-normal-install-and-an-upgrade-in-wix At least, you gave to use `UPGRADINGPRODUCTCODE` to detect upgrade scenario – Pavel Anikhouski Apr 29 '19 at 08:08

1 Answers1

0

Instead of running before RemoveFiles try running after InstallValidate. I believe RemoveFiles only occurs on an uninstall. InstallValidate will occur before the existing product is removed.