Wix:财产状况不佳

时间:2011-11-24 13:40:28

标签: wix windows-installer

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

任何人都可以向我解释为什么以下不起作用?

<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”。我已经尝试过调度自定义操作之前=“WixRemoveFoldersEx”和Before =“CostInitialise”与RemoveFoldersEx相关。

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


编辑:我将wix更新为此

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

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

以下情况会发生以下情况

  • 安装 - &gt;满足条件并安装组件
  • 重新安装 - &gt;条件未满足但组件仍然已卸载,然后重新安装
  • 卸载 - &gt;满足条件并卸载组件

我可以从中获取的是,该条件仅适用于安装过程,并且一旦安装了组件,就无法对其进行强制删除。


EDIT2:最后通过使用自定义操作设置的removefolderex属性来实现此功能。现在看似简单。

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

1 个答案:

答案 0 :(得分:2)

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

相关问题