开发者

WiX installer remove files on uninstall but not on upgrade

开发者 https://www.devze.com 2023-01-07 20:18 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消