- Clean target – this is an optional target. It is used to clean up the build folder;
<
target
name
=
"clean"
>
<
delete
>
<
fileset
>
<
include
name
=
"${build.dir}/*.*"
/>
</
fileset
>
</
delete
>
</
target
>
- Build target – builds the source files, embeds the rlinq file as a resource, defines the needed references and copies the necessary OA assemblies;
<
target
name
=
"build"
depends
=
"clean"
>
<
mkdir
dir
=
"${build.dir}"
/>
<
csc
target
=
"exe"
output
=
"${build.file}"
debug
=
"${debug}"
>
<
sources
>
<
include
name
=
"${source.dir}/*.cs"
/>
</
sources
>
<
resources
>
<
include
name
=
"${source.dir}/MyModel.rlinq"
/>
</
resources
>
<
references
>
<
include
name
=
"System"
/>
<
include
name
=
"System.Core"
/>
<
include
name
=
"System.Data"
/>
<
include
name
=
"Lib/Telerik.OpenAccess.dll"
/>
<
include
name
=
"Lib/Telerik.OpenAccess.35.Extensions.dll"
/>
</
references
>
</
csc
>
<
copy
todir
=
"${build.dir}"
>
<
fileset
basedir
=
"${lib.dir}"
>
<
include
name
=
"Telerik.OpenAccess.dll"
/>
<
include
name
=
"Telerik.OpenAccess.35.Extensions.dll"
/>
</
fileset
>
</
copy
>
<
copy
file
=
"${source.dir}/App.config"
tofile
=
"${build.file}.config"
/>
</
target
>
- Enhance target – runs the OpenAccess ORM Enhancer over the built project using the rlinq file as a metadata source;
<
target
name
=
"enhance"
depends
=
"build"
>
<
exec
program
=
"${enhancer.file}"
>
<
arg
value
=
"-assembly:"${build.file}" -xmlMapping:${source.dir}/MyModel.rlinq"
/>
</
exec
>
</
target
>
Note the exec task’s arguments listed above. They are providing the enhancer with the built assembly, which will be enhanced, and its metadata source. The metadata source will be used to obtain the metadata container which describes the domain model metadata. In this example the domain model is using an XML mapping. There can be scenarios where the model is defined using attributes or fluent mapping. It is possible to combine all of the mapping types in one OpenAccess ORM project.
I hope this tutorial proves useful for your NAnt build processes. The complete demo application can be found here.