WiX 安装程序会在卸载时删除文件,但不会在升级时删除文件
我有一个使用 WiX 安装程序安装的程序。
程序本身会在 [CommonAppDataFolder]\[MyAppName]\ 目录中创建许多文件。这些文件都具有相同的扩展名(我们称之为 .dat)。
在升级时,我想保留这些文件。
在卸载时,我想删除这些文件。
我目前正在删除文件,如下所示:
<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>
并且我这样做是为了方便升级:
<InstallExecuteSequence>
<RemoveExistingProducts After='InstallInitialize'/>
</InstallExecuteSequence>
现在,当我卸载时,.dat 文件将被正确删除。
但是,当我升级时,.dat 文件也会被删除。我猜是因为升级是在以前的版本上执行卸载。
我是否正确地处理这个问题?如何在升级时保留文件,同时在卸载时删除它们?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过向“RemoveExistingProducts”添加条件?这就是我要做的。
Have you tried adding a condition to the RemoveExistingProducts? This is what I would do.
一种选择是切换到小更新。这有很多限制,因此并不像听起来那么容易。
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.