Gypsy女郎的大秘密











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.



NAnt is a .Net build tool (which obviously similar to Ant). We have been using NAnt to create and deploy patches and I have been creating my own NAnt tasks to do the job. Recently I am thinking of enhancing the script that I have written couple of years ago.

Each user defined task has a TaskName, maybe some TaskAttribute too, and override ExecuteTask method. Let me just post an example of user defined task here.

Nant.UpdateDatabase.build.txt (save this as .build)



et cetera
Follow

Get every new post delivered to your Inbox.