在 WiX 中删除 XML 元素

发布于 2024-08-17 13:21:24 字数 33 浏览 3 评论 0原文

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

How do you delete/remove an element from an XML file in WiX?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

极致的悲 2024-08-24 13:21:24

给定一个包含以下内容的 .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">

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

Given a .config file with the following content:

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

To remove the item element with the type attribute set to 'value' this seems to do the trick:

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

This XmlConfig element is defined by the Wix "Utility" extension. To use that extension, you have to declare the UtilExtension namespace like this:

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

You also have to add -ext WixUtilExtension to the light.exe command options, or add a reference to "WixUtilExtension.dll" if you are authoring a wix project using votive in visual studio.

不弃不离 2024-08-24 13:21:24

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

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

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

否则您将收到错误:

The Component 元素包含未处理的扩展元素“util:Blah”。请确保已提供“http:⁄⁄schemas.microsoft.com⁄wix⁄UtilExtension”命名空间中元素的扩展。

I know this is old, but I searched everywhere for my issue and never could find it until I finally stumbled upon the answer. So maybe by posting here someone will find it useful.

In addition to the above answer, if using V4.0 the xmlns:util link should look like this:

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

Otherwise you will get the error:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文