Discussion:
[WiX-users] XmlConfig and uninstall
Andre Strik
2007-04-19 05:11:43 UTC
Permalink
Hi all,



Has anyone successfully used util:XmlConfig to modify an XML file on
uninstall?



Adding nodes is working, but removing them on uninstall is still beyond
me. Even with the VerifyPath attribute set, I'm still having no joy.



The below component successfully adds a <section> tag to a web.config,
but leaves it behind on uninstall.



<Component Id="XmlAddSection"
Guid="EB9B4575-467C-4BFB-ACA7-7C3E472A610F" KeyPath="yes">

<CreateFolder/>

<util:XmlConfig Id="XmlAddSectionDeclaration"
File="[DirWebInterfaces]web.config" Sequence="1" Action="create"
On="install" ElementPath="/configuration/configSections" Node="element"
Name="section"
VerifyPath="/configuration/configSections/section[\[]@name='newSection'[
\]]" />

<util:XmlConfig
Id="XmlAddSectionDeclarationName" File="[DirWebInterfaces]web.config"
Sequence="2" ElementPath="XmlAddSectionDeclaration" Name="name"
Value="newSection" >

<util:XmlConfig
Id="XmlAddSectionDeclarationType" File="[DirWebInterfaces]web.config"
Sequence="3" ElementPath="XmlAddSectionDeclaration" Name="type"
Value="blah" />

</util:XmlConfig>



<!-- This bit isn't working -->

<util:XmlConfig Id="XmlRemoveSectionDeclaration"
File="[DirWebInterfaces]web.config" Sequence="1" Action="delete"
On="uninstall" Node="element"
ElementPath="/configuration/configSections/section[\[]@name='newSection'
[\]]"
VerifyPath="/configuration/configSections/section[\[]@name='newSection'
[\]]"/>

</Component>



In the uninstall log, I see this:



ExecXmlConfig: Error 0x80070057: failed to remove created child element



That HR is something to do with an invalid character I believe?



Thanks,



Andre
Andre Strik
2007-04-19 05:33:49 UTC
Permalink
I knew that would happen. Solved it just after posting...



It looks like for an uninstall action, the @ElementPath points to the
parent node, while the @VerifyPath is relative to the @ElementPath.



So this works:



<util:XmlConfig Id="XmlRemoveSectionDeclaration"
File="[DirWebInterfaces]web.config" Sequence="1" Action="delete"
On="uninstall" Node="element"
ElementPath="/configuration/configSections"
VerifyPath="section[\[]@name='newSection'[\]]"/>



Cheers,



Andre







________________________________

From: wix-users-***@lists.sourceforge.net
[mailto:wix-users-***@lists.sourceforge.net] On Behalf Of Andre
Strik
Sent: Thursday, 19 April 2007 5:12 p.m.
To: wix-***@lists.sourceforge.net
Subject: [WiX-users] XmlConfig and uninstall



Hi all,



Has anyone successfully used util:XmlConfig to modify an XML file on
uninstall?



Adding nodes is working, but removing them on uninstall is still beyond
me. Even with the VerifyPath attribute set, I'm still having no joy.



The below component successfully adds a <section> tag to a web.config,
but leaves it behind on uninstall.



<Component Id="XmlAddSection"
Guid="EB9B4575-467C-4BFB-ACA7-7C3E472A610F" KeyPath="yes">

<CreateFolder/>

<util:XmlConfig Id="XmlAddSectionDeclaration"
File="[DirWebInterfaces]web.config" Sequence="1" Action="create"
On="install" ElementPath="/configuration/configSections" Node="element"
Name="section"
VerifyPath="/configuration/configSections/section[\[]@name='newSection'[
\]]" />

<util:XmlConfig
Id="XmlAddSectionDeclarationName" File="[DirWebInterfaces]web.config"
Sequence="2" ElementPath="XmlAddSectionDeclaration" Name="name"
Value="newSection" >

<util:XmlConfig
Id="XmlAddSectionDeclarationType" File="[DirWebInterfaces]web.config"
Sequence="3" ElementPath="XmlAddSectionDeclaration" Name="type"
Value="blah" />

</util:XmlConfig>



<!-- This bit isn't working -->

<util:XmlConfig Id="XmlRemoveSectionDeclaration"
File="[DirWebInterfaces]web.config" Sequence="1" Action="delete"
On="uninstall" Node="element"
ElementPath="/configuration/configSections/section[\[]@name='newSection'
[\]]"
VerifyPath="/configuration/configSections/section[\[]@name='newSection'
[\]]"/>

</Component>



In the uninstall log, I see this:



ExecXmlConfig: Error 0x80070057: failed to remove created child element



That HR is something to do with an invalid character I believe?



Thanks,



Andre

Loading...