NAnt – Changing CustomError setting in web.config

Couldn’t find any specific information on this one today when I was looking so hopefully this may help someone.

It’s easy enough to do an xmlpoke when you’ve got well formed xml tags, but what do you do when the attribute is within a single tag?

E.g.

<customErrors mode="RemoteOnly" />

 

The following code allows you to the change the attribute value.   Make sure you provide the full path to the attribute and prefix the attribute name with @ (see below).  The value can be a literal value or a pre-defined property value as seen below.

<xmlpoke file="${target.dir}\Web.config"
   xpath="/configuration/system.web/customErrors/@mode"
   value="${custom.error.mode}"/> 
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s