2

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;fullScreen=1"/>
</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;fullScreen=2"/>

<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?

goku_da_master
  • 4,257
  • 1
  • 41
  • 43

1 Answers1

5

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;fullScreen=2"/>

The credit goes to Gary from the nant-users mailing list, which I just subscribed to :)

Leigh
  • 28,765
  • 10
  • 55
  • 103
goku_da_master
  • 4,257
  • 1
  • 41
  • 43