Killer Nant Scripting Part 4

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>

View All of the Killer Nant Scripting Articles

Post a Comment

Your email is never shared. Required fields are marked *

*
*
Profile Picture

About Ian Lintner


I am a software developer, mostly web,  in Des Moines, Iowa. I take a very opinionated stand concerning development, you will never regret a simple design or architecture. My education was at Drake University in Biology and Computer Science. Offline I am recently married to my wife Heather. I try my hand at many hobbies currently I am gardening till the snow comes in.



My Current Projects


Des Moines Twitter Trends