WIX XmlConfig VerifyPath 转义

WIX XmlConfig VerifyPath escaping

我正在使用 WIX 在文件中添加 XML 元素。当我的 util:XmlConfig 元素具有如下 VerifyPath 属性时:

VerifyPath="/configuration/App/add[@key='ApiURL']"

什么都没发生。现在我将其更改为如下所示(基于我在代码库其他地方找到的一些其他代码):

VerifyPath="/configuration/App/add[\[]@key='ApiURL'[\]]"

并且它正在正确添加元素。这是什么转义,为什么有必要?

如果我正确理解了 XPath 规范及其在 Wix 工具集中对我的工作方式,这些字符表明工作将通过 add 属性完成,其中有是 key

的值
<configuration>
    <App>
        <add key='ApiURL'/>
    </App>
</configuration>

但我们需要朝这个方向看。具体我自己也没有查到。

我试图独立地找出与您相同问题的答案,我找到了回答您关于 Windows 安装程序中格式化类型的问题 here. This Whosebug answer led me to this document 的线索。

我已经复制了下面的相关文本,但简而言之,"[\[]" 是您如何获得文字 "[" 字符。

If a substring of the form [\x] is found, it is replaced by the character x , where x is one character, without any further processing. Only the first character after the backslash is kept; everything else is removed. For example, to include a literal left bracket ([), use [\[]. The text [\[]Bracket Text[\]] resolves to [Bracket Text].