Friday, 14 September 2007

NAnt task example - XmlPokeExtendedTask

NAnt has a XmlPoke task, which is good, but unfortunately it does not create the node if it does not already exists. I have created my XmlPokeExtendedTask which would create xml node with and the spcified attribute for me.

For example
/configuration/appSettings/add[@key='Some.Setting']/@value,10
/configuration/appSettings/add[@key='Some.Setting2']/@value,Low

the ouput XML will contains the following:
<configuration>
<appsettings>
<add key="Some.Setting" value="10">
<add key="Some.Setting2" value="Low">
</appsettings>
</confugration>


Here is the assembly and an example. Simply putting the dll into the NAnt folder would work because NAnt automatically include assemblies that are named *Tasks.dll.

No comments:

Post a Comment