简体   繁体   中英

WiX installer remove files on uninstall but not on upgrade

I have a program that installs with a WiX installer.

The program itself creates a number of files in the [CommonAppDataFolder]\\[MyAppName]\\ directory. These files all have the same extension (lets call it .dat).

On upgrading , I want to retain these files.
On uninstalling , I want to remove these files.

I am currently deleting the files as so:

<Directory Id='CommonAppDataFolder'>
  <Directory Id='MyCommonAppDataFolder' Name='MyAppName'>
    <Component Id='RemoveFilesComponent' Guid='71cb0cd8-8459-4a8f-89b7-f00977aa7b70'>
      <RemoveFile Id='RemoveFiles' Name='*.dat' On='uninstall'/>
    </Component>
  </Directory>
</Directory>

And I have this to facilitate upgrades:

<InstallExecuteSequence>
  <RemoveExistingProducts After='InstallInitialize'/>
</InstallExecuteSequence>

Now, when I uninstall, the .dat files are removed correctly.
However, when I upgrade, the .dat files are also removed. I guess because an upgrade is performing an uninstall on the previous version.

Am I approaching this problem correctly? How can I retain the files on upgrade, while removing them on uninstall?

这个主题可能会回答你的问题。

Have you tried adding a condition to the RemoveExistingProducts? This is what I would do.

<RemoveExistingProducts After='InstallInitialize'>(NOT UPGRADINGPRODUCTCODE) AND (Installed)</RemoveExistingProducts>

One option would be to switch to a minor update. That has a lot of restrictions so it isn't as easy as it sounds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM