How do you conditionally remove files during uninstall?

[亡魂溺海] 提交于 2019-12-24 07:19:04

问题


I have this WiX fragment:

<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>

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"

and

msiexec /xpath-to-msi.msi

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

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

with the same results.

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


回答1:


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:

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.



来源:https://stackoverflow.com/questions/20133400/how-do-you-conditionally-remove-files-during-uninstall

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!