UppercuT - Automated Builds - Custom Tasks

UppercuT provides hook points to custom tasks so that you can customize UppercuT without ever having to touch the files in BuildScripts. This makes it extremely easy to upgrade UppercuT versions when you keep your custom build scripts separated from UppercuT’s build scripts.

To add custom tasks, all you need to do is create them in a folder next to BuildScripts called BuildScripts.Custom.

These are the points were custom tasks are called (in order):

  • _compile.build calls BuildTasks.Custom\_compile.build just before it completes if the custom file exists (remember all of these are going back one directory, BuildTasks and BuildTasks.Custom should sit next to each other).
  • _ndepend.build calls BuildTasks.Custom\analyzers\_ndepend.build just before it completes if the custom file exists.
  • _analyze.build calls BuildTasks.Custom\_analyze.build just before it completes if the custom file exists.
  • _package.build calls BuildTasks.Custom\_package.build just before it completes if the custom file exists.
  • __master.build calls BuildTasks.Custom\__master.build just before it completes if the custom file exists (note the double underscore here).

If you add one of these files, you can call off to any custom tasks or other NAnt files you want.

What’s the best way to go about doing this? Make a copy of the task you want custom tasks with. Most of the time, people want to customize _package.build in some way.

Customize Package.Build

1. Go to the BuildScripts folder and select _package.build. Right click and select [Copy].

  Creating a custom task by starting from a task

2. Create a BuildScripts.Custom folder next to BuildScripts if one does not already exist.

  Creating the BuildScripts custom directory

3. In the BuildScripts.Custom folder, copy in the _package.build.

  BuildScripts custom directory

4. Open the newly copied file for editing. Remove all of the properties except:

<property name="dirs.current" value="${directory::get-parent-directory(project::get-buildfile-path())}" />
<property name="dirs.build" value="${dirs.current}\..\build_output" />
<property name="dirs.drop" value="${dirs.current}\..\code_drop" overwrite="false" />
<property name="app.drop.folder" value="app" overwrite="false" />

5. Remove all of the targets except for go and one that has copying in it. Change the name of the target you are keeping to something more appropriate. You can see here that I have renamed my target to add_setup_files.

<target name="add_setup_files">
  <echo message="Packaging setup files to ${dirs.drop}\app\Setup."/>
  <copy todir="${dirs.drop}\${app.drop.folder}\Setup">
    <fileset basedir="${dirs.build}\..\Setup">
      <include name="**/*.*" />
    </fileset>
  </copy>
</target>
6. In target “go”, set the depends property to just the remaining other targets in the custom packager file.
<target name="go" depends="add_setup_files" description="Packaging" />


7. This is the BuildScripts.Custom\_package.build file after our edits.

<?xml version="1.0" encoding="utf-8" ?>
<project name="Packager" default="go">
  <property name="dirs.current" value="${directory::get-parent-directory(project::get-buildfile-path())}" />
  <property name="dirs.build" value="${dirs.current}\..\build_output" />
  <property name="dirs.drop" value="${dirs.current}\..\code_drop" overwrite="false" />
  <property name="app.drop.folder" value="app" overwrite="false" />

  <target name="go" depends="add_setup_files" description="Packaging" />

  <target name="add_setup_files">
    <echo message="Packaging setup files to ${dirs.drop}\app\Setup."/>
    <copy todir="${dirs.drop}\${app.drop.folder}\Setup">
      <fileset basedir="${dirs.build}\..\Setup">
        <include name="**/*.*" />
      </fileset>
    </copy>
  </target>

</project>

8. And you can see when we call build.bat, our custom task is called!

command window showing call to custom task

 

With this knowledge you shall build.

 
kick it on DotNetKicks.com

Print | posted @ Thursday, May 21, 2009 10:46 PM

Comments on this entry:

Comments are closed.

Comments have been closed on this topic.