Targets Level 3: Actions
I finally have floated back to earth after my head trip about simplicity.
Actions are the meat of my Nant scripting methodology. This is the section where I break down the tasks into their atomic parts. This is where we will be telling nant what to do.
One of the standard tasks that usually needs to be accomplished is moving files from one directory to another. The biggest challenge is writing somewhat generic tasks. One example is a task to move just a web project without the code behinds or other files unnecessary for our web application to run.
These two tasks are examples of copy tasks I could use in deploying a web project, they both use the same variables for input and output. They accomplish one task such as copying aspx and ascx files to a directory, and they could be used as is in other projects, or if necessary slightly modified.
<target name="action.copy.pages"> <mkdir dir="${action.destination.dir}" />
<copy todir="${action.destination.dir}" overwrite="true" > <fileset basedir="${action.source.dir}"> <include name="**/*.aspx" /> <include name="**/*.ascx" /> </fileset> </copy>
<echo message="COPY PAGES AND CONTROLS: SUCCESS ${datetime::now()}" /> </target>
<target name="action.copy.resources"> <mkdir dir="${action.destination.dir}" />
<copy todir="${action.destination.dir}" overwrite="true" > <fileset basedir="${action.source.dir}"> <include name="**/*.htm" /> <include name="**/*.gif" /> <include name="**/*.jpg" /> <include name="**/*.png" /> <include name="**/*.css" /> <include name="**/*.js" /> </fileset> </copy>
<echo message="COPY RESOURCES COMPLETE: SUCCESS ${datetime::now()}" /> </target>












