How to integrate OpenAccess ORM and NAnt

Build Automation

Build automation is important part of software development. It encompasses many tasks – build integration, unit testing, code analysis and deployment. The goal is to automate the repetitive steps, to establish consistency and remove error-prone tasks.

Build Tools

The build tools are programs which organize the software builds by automating the build processes. Among the widely-used build tools in the .NET world are MS Build and NAnt. NAnt is an xml-based open-source build automation tool. This section describes the NAnt fundamentals.

OpenAccess ORM and NAnt

In this blog post I will demonstrate how to integrate OpenAccess ORM and NAnt. There are a few important steps that need to be implemented in order to automate an OpenAccess domain model using NAnt.

The NAnt build definition includes several targets which will be used to automate the build process for the given OpenAccess ORM domain model. A target is a set of tasks which are executable piece of code.

    • Clean target – this is an optional target. It is used to clean up the build folder;
    • Build target – builds the source files, embeds the rlinq file as a resource, defines the needed references and copies the necessary OA assemblies;
    • Enhance target – runs the OpenAccess ORM Enhancer over the built project using the rlinq file as a metadata source;

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. 

The complete demo application can be found here.