SourceForge Logo NCodeGen





Using NCodeGen with NAnt

NCodeGen features well-defined NAnt task that can be used in Automated Build Process

Parameters :

Attribute Description Required
basedir base folder - input and template files loaded form there false
package package folder false
template Address of template file (template name if package specified) true
input Address of XML input file false
ouput output file address true
parameters list of parameters that can be used in templates false
inputs for specifying multiple inputs false
foreach for specifying multiple templates with one input file (see below) false
engine template engine that NCodeGen uses (NVelocity,XSLT,Simple) false
Simplest form
<ncodegen basedir="packages\SQL" input="Database.xml" 
	template="Script.vm" output="output\db.sql"/>
Specifying Parameters
<ncodegen basedir="packages\Collections" template="Collection.vm" 
        <parameter name="Namespace" value="MyNamespace"/>
        <parameter name="Type" value="Task"/>
        <parameter name="Key" value="ID"/>
        <parameter name="Remove" value="true"/>
One Input with multiple templates

for each element returned form XPath Expression select NCodeGen process template file. output address can be parameterized with #Node# = element name

<ncodegen basedir="packages\SQL" input="Database.xml">
	<foreach select="/Input/Database/Tables/*">
		<template name="createtable.vm" 
	<foreach select="...">
Template with multiple inputs

for each input file in inputs fileset NCodeGen process template file. output address can be parameterized with #Input# = input file name

<ncodegen basedir="packages\SQL" template="spInsert.vm" 
		<includes name="Tables\*.xml"/>
Using Packages

using package instead of basedir is recommended.Package is NCodeGen mechanism for encapsulating templates,helpers and related constructs.

<ncodegen package="packages\NAnt" template="BuildFile" 
     	<parameter name="SolutionAddress" value="src\NCodeGen.sln"/>

Copyright © 2004, Edris Hasani Nasab Logo