我有一个NANT脚本,试图在我的web.config中更改URL值,但Nant一直在抛出此错误:

'=' is an unexpected token. The expected token is ';'. Line 1, position 80.

我将其追溯到Nant脚本的URL中的分号。首先,我在URL中有一个半隆的原因是因为web.config不喜欢AmperSands(&)。所以我不得不替换 &. 。这是我的web.config值:

<appSettings>
    <add key="myUrl" value="http://www.google.com/whatever?id=myId&amp;fullScreen=1"/>
</appSettings>

我能够在web.config中xmlpoke所有其他“添加键”,但这不是XPATH问题。这是Nant脚本:

<property name="myUrl" value="http://www.google.com/whatever?id=123456&amp;fullScreen=2"/>

<xmlpoke 
   file="${config.file}"
   xpath="/configuration/appSettings/add[@key = 'myUrl']/@value"
   value="${myUrl}">    
</xmlpoke>

因此,问题不是在web.config中的分号,而是在Nant脚本中的半隆。我想我需要以某种方式逃脱Nant脚本中的半隆。有人知道该怎么做或其他事情使它起作用吗?

有帮助吗?

解决方案

已经有16个小时了,没有任何人的窥视。对我来说幸运的是,经过几个小时的谷歌搜索,我找到了解决方案。

解决方案是使用 &amp;amp;. 。我不知道为什么要额外 amp; 但是它奏效了。所以现在我的Nant脚本看起来像:

<property name="myUrl" value="http://www.google.com/whatever?id=123456&amp;amp;fullScreen=2"/>

荣誉是 来自Nant用户邮寄列表的Gary, ,我刚刚订阅:)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top