WiX XmlConfig: Elements not removed on uninstall

自闭症网瘾萝莉.ら 提交于 2019-12-24 07:55:15

问题


I'm having difficulty removing on uninstall the elements that I add to an XML file on install. Here's my setup: The XML file already exists on the machine before install and can't be remove after install because this installer is for an "add-in" to an application. I do add some elements to the XML file on install, but only want to remove some of those elements on uninstall.

I've been searching online for answers and can't find any that fit my situation. I've tried copying the syntax of this post: Deleting XML elements in WiX, but it still isn't working. However, on install I do remove the existing elements so as to do a replace on install if the elements already exist. So, in other words, deleting an element works on install, but with the exact same tag (except the Id attr of course) it doesn't work on uninstall.

Here's my code:

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


I finally figured out the problem. I realized that [FILE_DIR_PATH] had no value on uninstall. This property was obtained by a RegistrySearch. So, all I had to do to fix it was to declare the property as Secure:

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

I found out that this would solve some problems while trying to fix repair issues with another installer. I found this post useful: Wix installer blanks out registry setting when repairing.

I also found a blog post by Rob Mensching useful with issues of this nature: http://robmensching.com/blog/posts/2010/5/2/The-WiX-toolsets-Remember-Property-pattern



来源:https://stackoverflow.com/questions/13886728/wix-xmlconfig-elements-not-removed-on-uninstall

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