views:

33

answers:

1

I have a nant script that is trying to change a URL value in my web.config but Nant keeps throwing this error:

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

I traced it down to the semicolon in the URL of the nant script. The reason I have a semicolon in the URL in the first place is because the web.config doesn't like ampersands (&). So I had to replace & with &. Here's my web.config value:

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

I'm able to xmlpoke all the other "add keys" in the web.config but this one, so it's not an xpath issue. Here's the nant script:

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

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

So the problem isn't with the semicolon in the web.config, but with the semicolon in the nant script. I guess I need to somehow escape the semicolon in the nant script. Anyone know how to do this or something else to get it to work?

+1  A: 

It's been 16 hours and not a peep from anyone. Lucky for me I found the solution after a few hours of googling.

The solution is to use &amp;amp;. I have no idea why the extra amp; but it worked. So now my nant script looks like so:

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

The credit goes to Gary from the nant-users mailing list: http://www.mail-archive.com/[email protected]/msg07956.html (which I just subscribed to :))

goku_da_master