2010-01-15 56 views

回答

20

考慮有以下內容的config文件:

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

要刪除設置爲「價值」的類型屬性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 WixUtilExtensionlight.exe命令選項,或者添加引用「WixUtilExtension.dll」如果你在創作威克斯項目在視覺工作室中使用votive。

+1

ElementPath點到VerifyPath的父級。非常有幫助,謝謝! – 2012-05-17 12:43:04

+0

使用WiX 3.6,我還必須在蠟燭中添加「-ext WixUtilExtension」。 – Chris 2013-01-03 15:53:57

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.

+0

感謝您爲v4添加信息 – 2013-05-01 07:04:11