Information Technology Reference
In-Depth Information
The high-level steps for building your software go something like
this.
1. Create your build using a build scripting tool like NAnt, Rake,
Ant, or Maven. Keep it simple at first; you can add more pro-
cesses as you go.
2. Add each process (clean, compile, etc.) of the Integrate button
within the build script.
3. Run the script from an IDE or the command line to build software.
Listings 4-2 through 4-6 demonstrate examples using the NAnt
build tool for the .NET platform; however, you can achieve the same
effect with other build scripting tools, such as Ant or Maven for Java,
MSBuild for .NET, and Rake for Ruby, to name a few. The issue is not
so much which tool you choose to use, but you should ideally use an
existing build tool rather than creating a custom solution.
Listing 4-2 shows a NAnt script that uses the delete task to remove
any directories and files before a new build. This reduces any chance
that files from a previous build will adversely affect the new build.
LISTING 4-2
Clean Generated Directories Using NAnt
<target name="clean">
<delete dir="${build.dir}" verbose="true" failonerror="false"/>
<delete dir="${dist.dir}" verbose="true" failonerror="false"/>
<delete dir="${reports.dir}" verbose="true" failonerror="false"/>
</target>
Listing 4-3 demonstrates C# compilation using the csc task. This
task will compile all of the files in a certain directory and move the
generated .dll file to a different directory. The second part of this
example demonstrates the execution of a SQL script that runs a data
definition script to create the tables in a database.
Compile and Rebuild Database Using NAnt
LISTING 4-3
<target name="build">
<csc target="library" debug="${build.debug}"
output="${build.dir}\bin\${config}\${nant.project.name}.dll">
<sources failonempty="true">
<include name="${project.localpath}/**/*.cs" />
</sources>
</csc>
</target>
Search WWH ::




Custom Search