Question
On the XmlFile element, does Permanent="yes"
means it will not attempt to remove the changes applied by XmlFile during install? If this is not right, how can I copy an XML file to install folder during installation, apply changes to it, and then successfully remove that file during uninstall?
Background
I am creating an MSI file with WiX. I am using the XmlFile element to change an XML file after I install it. I am confused about whether changes made with XmlFile get backed out during uninstall, and how that relates to the XmlFile element's Permanent attribute.
I've seen conflicting answers to the question of whether changes made during install with XmlFile get backed out on uninstall. First, there is this SO answer by Stein Åsmul, which purports to quote WiX developer Bob Arnson (emphasis mine):
"You can do everything (and more) that XmlFile supports with XmlConfig but it requires extra authoring that's not necessary with XmlFile. XmlFile is best at modifying XML files that you're installing (e.g., to add an attribute reflecting the installed path of a file); it can't remove the modifications at uninstall time but if your setup installed the file, it will be uninstalled anyway. XmlConfig is best at modifying shared XML files because it supports uninstalling the modifications."
Unfortunately the source for that quote is a dead link, so I can't check to see if there are caveats, or what version of WiX Toolset it applies to.
This XML tutorial on FireGiant appears to contradict that quote (again, emphasis mine):
So, to carry out the modifications we planned, we need the following entries (note that we have to provide our own sequencing, this is important to ensure that the changes will be removed in the proper reverse order upon uninstallation):
The FireGiant tutorial goes on to show XML elements modified like this:
<Component Id='Settings' Guid='YOURGUID-574D-4A9A-A266-5B5EC2C022A4'>
<File Id='XmlSettings' Name='settings.xml' DiskId='1' Source='settings.xml' Vital='yes' />
<util:XmlFile Id='XmlSettings1' File='[INSTALLDIR]settings.xml'
Action='createElement' Name='add' ElementPath='//settings' Sequence='1' />
<util:XmlFile Id='XmlSettings2' File='[INSTALLDIR]settings.xml'
Action='setValue' Name='key' Value='a_key' ElementPath='//settings/add' Sequence='2' />
<util:XmlFile Id='XmlSettings3' File='[INSTALLDIR]settings.xml'
Action='setValue' Name='value' Value='a_value' ElementPath='//settings/add' Sequence='3' />
<util:XmlFile Id='XmlSettings4' File='[INSTALLDIR]settings.xml'
Action='setValue' Value='key_item' ElementPath='//settings/add' Sequence='4' />
<util:XmlFile Id='XmlSettings5' File='[INSTALLDIR]settings.xml'
Action='createElement' Name='inside' ElementPath='//settings/add' Sequence='5' />
<util:XmlFile Id='XmlSettings6' File='[INSTALLDIR]settings.xml'
Action='setValue' Value='inside_item' ElementPath='//settings/add/inside' Sequence='6' />
</Component>
I am using WiX Toolset version 3.11.2. I suspect the FireGiant tutorial is newer and thus more likely to be correct. The documentation for the XmlFile element doesn't discuss this one way or another. It does, however, seem to hint that an attribute named Permanent
might come into play. Valid values for Permanent are yes
or no
, but the description of the attribute is not specific as to what the effect will be for each value. This is the complete description of the attribute Permanent
:
Specifies whether or not the modification should be removed on uninstall. This has no effect on uninstall if the action was deleteValue.
I'm left guessing whether I am interpreting the meaning of the Permanent attribute correctly.
So here's my question: Does Permanent="yes"
means it will not attempt to remove the changes applied during install? If this is not right, how can I copy an XML file to install folder during installation, apply changes to it, and then successfully remove that file during uninstall?
Notes
- I am using WiX Toolset version 3.11.2.