If you are using active generation of templates, here is a build script that invokes CodeSmith:
<?xml version="1.0" encoding="unicode"?>
<project name="nant" default="compile" xmlns="http://nant.sf.net/schemas/nant.xsd">
<property name="CodeSmith" value="cs.exe" />
<target name="compile" depends="genruntime" description="Compile entire solution">
<solution solutionfile="src\project.sln" configuration="release">
<webmap>
<map url="http://localhost/ProjectWeb" path="src\ProjectWeb" />
</webmap>
</solution>
</target>
<target name="genruntime" description="Generate O/R Classes for the runtime library">
<exec program="${CodeSmith}" basedir="tools\codesmith" workingdir="src\ProjectWeb.Runtime">
<arg value="/t: Templates\ClassGenerator.cst" />
<arg value="/ps: ORClasses.xml" />
</exec>
</target>
This script was influenced by Mike Roberts' article How to setup a .NET Development Tree. (Thanks Mike!) I use a property to alias the CodeSmith command (cs.exe) because I kept thinking csc (which compiles C# code).