Wix:财产条件不起作用 [英] Wix: condition on property not working

查看:31
本文介绍了Wix:财产条件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 util:RemoveFolderEx 元素,我只想在卸载程序时运行它.我把它放在它自己的组件中,然后在属性上设置一个条件,以确定它是否应该被包含.

I have a util:RemoveFolderEx element that I only want to run when the program is being uninstalled. I put it inside its own component then set up a condition on a property as to whether it should be included.

谁能向我解释为什么以下方法不起作用?

Can anyone explain to me why the following doesn't work?

<Property Id='UNINSTALLMODE' Value="FALSE"></Property>

<DirectoryRef Id="DATADIR">        
    <Component Id="C.RemoveDataFolder" Guid="myguid" KeyPath="yes">
        <util:RemoveFolderEx On="uninstall" Property="DATADIR" ></util:RemoveFolderEx>
        <Condition>(UNINSTALLMODE="TRUE")</Condition>
    </Component>
</DirectoryRef>

<CustomAction Id="CA.SetUninstallMode" Property="UNINSTALLMODE" Value="TRUE" />

<InstallExecuteSequence>
    <Custom Action="CA.SetUninstallMode" Before="WixRemoveFoldersEx" >(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>            

我检查了日志,卸载软件时自定义操作正确地将 UNINSTALLMODE 设置为TRUE".在安装和重新安装时它是FALSE".我已尝试将自定义操作安排在与 RemoveFoldersEx 相关的 Before="WixRemoveFoldersEx" 和 Before="CostInitialise".

I've checked the logs and the custom action correctly sets UNINSTALLMODE to "TRUE" when uninstalling the software. On install and reinstall it is "FALSE". I've tried the custom action to be scheduled Before="WixRemoveFoldersEx" and Before="CostInitialise" which are relevant to the RemoveFoldersEx.

非常感谢任何帮助,这让我发疯!尼尔

Any help is much appreciated, this is driving me nuts! Neil

我将 wix 更新为此

I updated the wix to this

<Property Id='P.INSTALLMODE' Value='0'></Property>
<Property Id='P.UNINSTALLMODE' Value='0'></Property>

<DirectoryRef Id="DATADIR">        
    <Component Id="C.RemoveDataFolder" Guid="myguid" KeyPath="yes">
        <util:RemoveFolderEx On="uninstall" Property="DATADIR" ></util:RemoveFolderEx>
        <Condition>(P.INSTALLMODE = 1) OR (P.UNINSTALLMODE = 1)</Condition>
    </Component>
</DirectoryRef>

<CustomAction Id="CA.SetInstallModeToTrue" Property="P.INSTALLMODE" Value='1' />
<CustomAction Id="CA.SetUninstallModeToTrue" Property="P.UNINSTALLMODE" Value='1' />

<InstallExecuteSequence>
    <RemoveExistingProducts Before="InstallInitialize" />            

    <Custom Action="CA.SetInstallModeToTrue" Before="ValidateProductID" >(NOT UPGRADINGPRODUCTCODE) AND (NOT PREVIOUSVERSIONSINSTALLED)</Custom>
    <Custom Action="CA.SetUninstallModeToTrue" Before="ValidateProductID" >(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>

自定义操作在从注册表读取 DATADIR 值之后和 CostInitialize 之前立即运行.

The custom actions run immediately after the DATADIR value is read from the registry and before the CostInitialize.

以下情况会发生什么

  • 安装 -> 条件满足,组件安装
  • 重新安装 -> 条件未满足但组件仍被卸载然后重新安装
  • 卸载 -> 条件满足,组件被卸载

我能从中得出的结论是,该条件仅适用于安装过程,并且一旦安装了组件,就不可能对其施加移除条件.

All I can take from this is that the condition is only applicable for the installation procedure and once a component is installed it is not possible to impose a condition on it for being removed.

最终通过使用由自定义操作设置的 removefolderex 的属性来实现此目的.现在看起来很简单.

Finally got this working by using a property for the removefolderex which is set by a custom action. Seems simple now.

<Property Id='P.REMOVEDATAFOLDER' Secure='yes' />

<DirectoryRef Id="DATADIR">        
    <Component Id="C.RemoveDataFolder" Guid="myguid" KeyPath="yes">
        <util:RemoveFolderEx On="uninstall" Property="P.REMOVEDATAFOLDER" />
    </Component>
</DirectoryRef>

<CustomAction Id="CA.SetDataFolder" Property="P.REMOVEDATAFOLDER" Value='[DATADIR]' />

<InstallExecuteSequence>           
    <Custom Action="CA.SetDataFolder" Before="ValidateProductID" >(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>  

推荐答案

安装时包含 RemoveFolderEx 元素的组件的条件为 False.这意味着未安装该组件.如果它没有安装,它显然也不会被卸载.因此,即使卸载时条件驱动属性为 True,CA 也不会运行,因为它所依赖的组件没有安装.

The condition of the component, which holds the RemoveFolderEx element, is False on install. This means the component is not installed. If it's not installed, it obviously won't be uninstalled, either. Hence, even if the condition-driving property is True on uninstall, the CA won't run because the component it depends upon was not installed.

这篇关于Wix:财产条件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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