Question

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>
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top