【问题标题】:Deleting XML elements in WiX在 WiX 中删除 XML 元素
【发布时间】:2013-05-01 15:03:45
【问题描述】:

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

【问题讨论】:

    标签: xml wix wix3


    【解决方案1】:

    给定一个包含以下内容的 .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“实用程序”扩展定义。要使用该扩展,您必须像这样声明 UtilExtension 命名空间:

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

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

    【讨论】:

    • ElementPath 指向 VerifyPath 的父级。很有帮助,谢谢!
    • 使用 WiX 3.6,我还必须将 -ext WixUtilExtension 添加到蜡烛。
    【解决方案2】:

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

    除了上述答案,如果使用 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.

    【讨论】:

    • 感谢您添加 v4 的信息
    猜你喜欢
    • 2013-05-21
    • 2014-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-10
    • 1970-01-01
    相关资源
    最近更新 更多