SourceForge Logo NCodeGen


NCodeGen

Documentation

Community

Related

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
Samples
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" 
		output="output\Collection.cs">
    <parameters>
        <parameter name="Namespace" value="MyNamespace"/>
        <parameter name="Type" value="Task"/>
        <parameter name="Key" value="ID"/>
        <parameter name="Remove" value="true"/>
    </parameters>
</ncodegen>
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" 
			output="output\table_#Node#.sql"/>
	</foreach>
	<foreach select="...">
		....
	</foreach>
</ncodegen>
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" 
	output="output\#Input#.sql">
 	<inputs>
		<includes name="Tables\*.xml"/>
 	</inputs>
</ncodegen>
 
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" 
	output="output\NAnt.build">
	<parameters>
     	<parameter name="SolutionAddress" value="src\NCodeGen.sln"/>
	</parameters>
</ncodegen>
 

Copyright © 2004, Edris Hasani Nasab
SourceForge.net Logo