如何在卸载过程中有条件地删除文件? [英] How do you conditionally remove files during uninstall?

查看:101
本文介绍了如何在卸载过程中有条件地删除文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个WiX片段:

<Component Id="AppData" Guid="{30967EFB-4B86-4EBB-8486-5271D051082E}">
    <Condition>NOT KEEPAPPDATA</Condition>
    <RemoveFile Id="PurgeAppData" Name="*.*" On="uninstall" />
    <RemoveFolder Id="RemoveAppDataFolder" On="uninstall" />
</Component>

程序存储数据的应用程序数据下目录的相应<Directory>元素中的

.但是两者

in the appropriate <Directory> element for the directory under application data that the program stores data. However both

msiexec /xpath-to-msi.msi KEEPAPPDATA="TRUE"

msiexec /xpath-to-msi.msi

删除文件夹,因此该条件不起作用.我也尝试过这种情况:

remove the folder, so the condition is not working. I have also tried this condition:

<Condition>KEEPAPPDATA == ""</Condition>

具有相同的结果.

在卸载过程中将参数传递给msiexec以更改行为的正确方法是什么?看来参数只是被忽略了.

What is the correct way of passing a parameter to msiexec to change behaviour during uninstall? It seems that parameters are just getting ignored.

推荐答案

默认情况下,卸载过程中不评估默认组件条件.这是类似的 Stackoverflow问题,来自Rob Mensching的回答.他建议使用传递"属性.来自文档:

By default component conditions are not evaluated during uninstall. Here is a similar Stackoverflow question with an answer from Rob Mensching. He suggests using Transitive attribute. From documentation:

如果此属性设置为是",则安装程序将在重新安装时重新评估条件"中的语句值.如果该值以前是False,并且已更改为True,则安装程序将安装该组件.如果该值以前是True,并且已更改为False,则即使该组件具有其他产品作为客户端,安装程序也会删除该组件.

If this attribute is set to 'yes', the installer reevaluates the value of the statement in the Condition upon a reinstall. If the value was previously False and has changed to True, the installer installs the component. If the value was previously True and has changed to False, the installer removes the component even if the component has other products as clients.

这篇关于如何在卸载过程中有条件地删除文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆