删除WiX中的XML元素

时间:2010-01-15 00:59:59

标签: xml wix wix3

如何从WiX中的XML文件中删除/删除元素?

2 个答案:

答案 0 :(得分:20)

给定一个包含以下内容的.config文件:

<configuration>
 <thingy>
  <stuff>
   <item type='value' />
   <item type='value2' />
  </stuff>
 </thingy>
</configuration>

要删除type属性设置为'value'的item元素,这似乎可以解决问题:

<util:XmlConfig
  On="install"
  Action="delete"
  Id="RemoveAnElement"
  Node="element"
  File="Application.dll.config"
  VerifyPath="/configuration/thingy/stuff/item[\[]@type='value'[\]]"
  ElementPath="/configuration/thingy/stuff"
  Sequence="100"
/>

XmlConfig元素由Wix“Utility”扩展名定义。要使用该扩展,您必须声明UtilExtension命名空间,如下所示:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
   xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

如果要在visual studio中使用votive创作wix项目,还必须将-ext WixUtilExtension添加到light.exe命令选项,或添加对“WixUtilExtension.dll”的引用。

答案 1 :(得分:4)

我知道这已经过时了,但我到处寻找我的问题,直到我最终偶然发现答案才发现它。所以也许通过在这里张贴,有人会发现它很有用。

除了上面的答案,如果使用V4.0,xmlns:util链接应如下所示:

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" 
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util" >

否则你会收到错误:

The Component element contains an unhandled extension element 'util:Blah'. Please ensure that the extension for elements in the 'http:⁄⁄schemas.microsoft.com⁄wix⁄UtilExtension' namespace has been provided.