使用 XmlFile 编写的安装时更改是否在卸载期间被撤销?

Are install-time changes authored with XmlFile reversed during uninstallation?

问题

XmlFile element 上,Permanent="yes" 是否意味着它不会尝试删除 XmlFile 在安装期间应用的更改?如果这不正确,我如何在安装过程中将 XML 文件复制到安装文件夹,对其应用更改,然后在卸载过程中成功删除该文件?

背景

我正在使用 WiX 创建 MSI 文件。安装后,我正在使用 XmlFile 元素更改 XML 文件。我对使用 XmlFile 所做的更改是否在卸载过程中被取消感到困惑,以及这与 XmlFile 元素的 Permanent 属性有何关系。

对于在使用 XmlFile 安装期间所做的更改是否会在卸载时取消的问题,我看到了相互矛盾的答案。首先,有 this SO answer by Stein Åsmul,它声称引用 WiX 开发人员 Bob Arnson(强调我的):

"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."

不幸的是,该引用的来源已失效 link,因此我无法查看是否有警告,或者它适用于哪个版本的 WiX 工具集。

XML tutorial on FireGiant 似乎与该引用相矛盾(再次强调我的):

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

FireGiant 教程继续显示 XML 个修改如下的元素:

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

我使用的是 WiX 工具集 3.11.2 版。我怀疑 FireGiant 教程较新,因此更可能是正确的。 documentation for the XmlFile element 没有以这种或那种方式讨论这个问题。但是,它似乎暗示名为 Permanent 的属性可能会起作用。 Permanent 的有效值为 yesno,但属性的描述并未具体说明每个值的效果。这是属性的完整描述 Permanent:

Specifies whether or not the modification should be removed on uninstall. This has no effect on uninstall if the action was deleteValue.

我在猜测我是否正确解释了 Permanent 属性的含义。

所以这是我的问题:Permanent="yes" 是否意味着它不会尝试删除安装期间应用的更改?如果这不正确,我如何在安装过程中将 XML 文件复制到安装文件夹,对其应用更改,然后在卸载过程中成功删除该文件?

备注

XmlFile 唯一可以“撤消”的更改是 Action="createElement" —— 因为那只会变成删除指定的元素。本教程使用 XmlFile 个可以撤消的元素——创建元素并在其中设置值——所以它是准确的。

XmlConfig 的创建是为了允许在卸载时进行任意 XML 修改和取消修改。