WiX XmlConfig:卸载时未删除元素

时间:2012-12-14 21:46:12

标签: xml wix wix3.6 wix-extension

我在卸载时无法删除我在安装时添加到XML文件的元素。这是我的设置:XML文件在安装之前已经存在于计算机上,并且在安装后无法删除,因为此安装程序用于应用程序的“加载项”。我在安装时向XML文件添加了一些元素,但只想在卸载时删除其中的一些元素。

我一直在网上寻找答案,找不到符合我情况的任何东西。我已经尝试复制这篇文章的语法:Deleting XML elements in WiX,但它仍然无效。但是,在安装时,我会删除现有元素,以便在元素已存在时进行安装替换。因此,换句话说,删除元素在安装时有效,但使用完全相同的标记(当然除了Id attr),它在卸载时不起作用。

这是我的代码:

<Component Id="C_Component" Guid="GUID-HERE">
    <File Id="MainProductFile" ... />
    <!-- XmlConfigs for installation are here -->
    <util:XmlConfig Id="XMLDEL_binding"
              File="[FILE_DIR_PATH]\File.config"
              Sequence="1"
              On="uninstall"
              Action="delete"
              ElementPath="/configuration/system.serviceModel/bindings/customBinding"
              VerifyPath="/configuration/system.serviceModel/bindings/customBinding/binding[\[]@name='!(wix.binding.name)'[\]]"
              Node="element" />
    <util:XmlConfig Id="XMLDEL_endpoint"
              File="[FILE_DIR_PATH]\File.config"
              Sequence="2"
              On="uninstall"
              Action="delete"
              ElementPath="/configuration/system.serviceModel/client"
              VerifyPath="/configuration/system.serviceModel/client/endpoint[\[]@name='!(wix.endpoint.name)' and @bindingConfiguration='!(wix.endpoint.bindingConfiguration)'[\]]"
              Node="element" />
</Component>

1 个答案:

答案 0 :(得分:1)

我终于找到了问题所在。我意识到[FILE_DIR_PATH]对卸载没有任何价值。此属性由RegistrySearch获得。因此,我必须做的就是将属性声明为Secure

<Property Id="FILE_DIR_PATH" Secure="yes">
    <RegistrySearch ... />
</Property>

我发现这可以解决一些问题,同时尝试修复其他安装程序的修复问题。我觉得这篇文章很有用:Wix installer blanks out registry setting when repairing

我还发现Rob Mensching的博客文章对这种性质的问题非常有用:http://robmensching.com/blog/posts/2010/5/2/The-WiX-toolsets-Remember-Property-pattern