0

I'm using WIX to code my installer. The application being installed has a database file that needs to be removed only upon uninstallation, and not touched in case of a repair, reinstallation or an upgrade.

I coded it as such:

        <Component Id='CompIDRemDataFile' Guid='{---gui--}'>
          <RemoveFile Id="idRemDataFile" Name="program_database.db" On="uninstall" Property="MyDataFolderPath" />
          <RegistryValue Id="RegRemDataFile" Root="HKCU" Key="Software\My Company\App name"
                         Name="11352" Value="1" Type="integer" KeyPath="yes" />

But I just learned that if I upgrade from an older version to a later one, this file is also deleted. What shall I change to prevent that?

c00000fd
  • 20,994
  • 29
  • 177
  • 400
  • You should post the WiX that does the upgrade, in particular the sequencing of the major upgrade because that affects how the upgrade works. – PhilDW Jan 12 '17 at 18:28
  • @PhilDW: Thanks. I don't think I have a `MajorUpgrade` element. Can you explain where I need it and how to configure it? – c00000fd Jan 12 '17 at 20:37

1 Answers1

1

The file overwrite rules include one that says updated data files will never be overwritten:

Neither file has a version

That means that patches, repairs, and major upgrades sequenced after InstallExecute will not replace the database, which has presumably been updated. There is no "reinstallation" in Windows Installer because the same MSI cannot be installed twice - the product will go into maintenance mode.

WiX major upgrade is here:

Majorupgrade element

How to implement major upgrade

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • You know I saw that too and tried it, but I can't figure out that WiX/MSI stuff. So I ended up writing a [custom action](http://stackoverflow.com/a/17608049/843732) where I can control all that stuff from within a C++ library. (At least I know what I'm doing there.) – c00000fd Jan 14 '17 at 00:57