Search code examples
wixwindows-installer

Downgrade removes new versions of executables but does not reinstall old versions


I have build two versions of my application installer. A version 1.0.0.0 and a version 1.0.1.0. In a prebuild step the application's executables are spiked with the selected version.

In order to allow downgrades the attribute AllowDowngrades in MajorUpgrade is set to 'yes'.

After installing 1.0.0.0 I upgrade the installation by running the 1.0.1.0 installer. The executables are properly upgraded. Then I run the 1.0.0.0 installer again to downgrade the installation back to 1.0.0.0. The installation completes and the executables with version 1.0.1.0 are removed; But the executables with version 1.0.0.0 are not reinstalled. They are just missing.

I do not understand why this is happening. I could understand if the installer had refused to overwrite newer executables, but why are the newer executables removed? Is there something else I have to do to make downgrades possible?

The beginning of my Product.wxs:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <!-- Including defines. -->
  <?include Defines.wxi ?>
  <Product Id="*"
        Name="$(var.ProductName) $(var.MajorMinorVersion)"
        Language="1033"
        Version="$(var.ProductVersion)"
        Manufacturer="$(var.Manufacturer)"
        UpgradeCode="$(var.UpgradeGuid)">

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade Schedule="afterInstallInitialize" AllowDowngrades='yes' AllowSameVersionUpgrades='no' />
    ...

Solution

  • REINSTALLMODE had to be changed from default omus to amus:

    <Property Id="REINSTALLMODE" Value="amus" />
    

    From Microsoft documentation:

    o   Reinstall if the file is missing or is an older version.
    a   Force all files to be reinstalled, regardless of checksum or version.
    

    With this change the executables are reinstalled on the downgrade in the right version.