2 <project name="Castle" xmlns="http://nant.sf.net/release/0.85/nant.xsd">
5 This file contains common tasks tailored specifically for the Castle
6 build process. The goal was to define all the actions in this file, so
7 that actual project build files only have to configure a few variables
8 and call tasks in this file.
12 <property name="root.dir" value="..\.." />
13 <include buildfile="${root.dir}/build-common/common-project.xml" />
15 These lines should be placed at the top level under the <project>
16 element. Property root.dir defines a relative path to the root of the
17 distribution, that is, Castle directory.
19 After including the file, a target should be defined to initialize
20 configuration variables according to the project being built.
21 The standard of this target is init (but any other name can be chosen).
22 The init target should depend on (or call) target common.init defined
25 Other predefined targets are:
27 - common.compile-tests
28 compile NUnit tests and copy App.config file to the output directory,
32 compile a DLL, generating the documentation and using Clover if enabled.
34 - common.generate-assemblyinfo, common.generate-assemblyinfoversion
35 generate an AssemblyInfo.cs or AssemblyInfoVersion.cs file from
36 assembly.* NAnt properties.
39 run compiled NUnit tests.
41 All compile/run targets put the output in build.dir. Common.compile*
42 targets use source fileset with id="project.sources", assembly fileset
43 with id="project.references" and resource fileset with id="project.resources"
44 to compile the project. The source and resource filesets are optional.
48 <include buildfile="common.xml" />
50 <target name="common.build">
53 <buildfiles refid="buildfiles.all" />
58 <target name="common.compile-tests"
59 description="Compile NUnit tests and copy App.config file to the output directory, if it exists.">
63 define="${current.build.defines}"
64 debug="${build.debug}"
65 warnaserror="${build.warnaserrors}"
66 output="${build.dir}/${project::get-name()}.dll"
67 rebuild="${build.rebuild}"
69 <sources refid="project.sources" />
70 <references refid="project.references" />
71 <resources refid="project.resources" />
72 <arg line="${csc.keyfile}" if="${assembly.sign}" />
73 <arg line="${csc.args}" />
76 <!-- Check if there is a framework specific config file and use that -->
77 <property name="app.config.src" value="${src.dir}/App-${framework::get-target-framework()}.config" />
78 <if test="${file::exists(app.config.src)}">
80 file="${app.config.src}"
81 tofile="${build.dir}/${project::get-name()}.dll.config"
84 <call target="common.configure-tests" />
85 <property name="app.config.src.found" value="true" />
87 <!-- In case there was no framework specific config check if there is a framework neutral file and use that. -->
88 <property name="app.config.src" value="${src.dir}/App.config" />
89 <if test="${file::exists(app.config.src)}" unless="${property::exists('app.config.src.found')}">
91 file="${app.config.src}"
92 tofile="${build.dir}/${project::get-name()}.dll.config"
95 <call target="common.configure-tests" />
100 <target name="common.configure-tests"
101 description="Configure tests for running NUnit tests.">
103 <property name="app.config" value="${build.dir}\${project::get-name()}.dll.config" />
105 <!-- make sure the config file is writable -->
106 <attrib file="${app.config}" readonly="false" />
110 xpath="/configuration/appSettings/add[@key='tests.src']/@value"
116 <target name="common.compile-dll"
117 description="Compile sources into a DLL">
121 define="${current.build.defines}"
122 debug="${build.debug}"
123 optimize="${build.optimize}"
124 warnaserror="${build.warnaserrors}"
125 output="${build.dir}\${project::get-name()}.dll"
126 doc="${build.dir}\${project::get-name()}.xml"
127 rebuild="${build.rebuild}"
130 <warning number="1591" unless="${build.warnmissingdocs}" /> <!-- No XML comment for publicly visible member -->
132 <sources refid="project.sources" />
133 <references refid="project.references" />
134 <resources refid="project.resources" />
135 <arg line="${csc.keyfile}" if="${assembly.sign}" />
136 <arg line="${csc.args}" />
140 <target name="common.compile-website">
141 <property name="bin.dir" value="${src.dir}/bin" />
142 <mkdir dir="${bin.dir}" />
143 <delete file="${bin.dir}/${project::get-name()}.pdb" failonerror="false" /> <!-- To prevent 1.1 compiler from crashing when switching from a 2.0 build -->
144 <property name="build.dir" value="${bin.dir}" />
146 <call target="common.compile-dll" />
147 <call target="common.copy-references" />
150 <target name="common.copy-references">
151 <foreach item="File" property="reference">
153 <items refid="project.references" />
156 <copy file="${reference}" todir="${bin.dir}" overwrite="${build.rebuild}" />
161 <target name="common.compile-exe"
162 description="Compile sources into a console executable">
166 define="${current.build.defines}"
167 debug="${build.debug}"
168 optimize="${build.optimize}"
169 warnaserror="${build.warnaserrors}"
170 output="${build.dir}\${project::get-name()}.exe"
173 <warning number="1591" unless="${build.warnmissingdocs}" /> <!-- No XML comment for publicly visible member -->
175 <sources refid="project.sources" />
176 <references refid="project.references" />
177 <resources refid="project.resources" />
178 <arg line="${csc.keyfile}" if="${assembly.sign}" />
179 <arg line="${csc.args}" />
183 <target name="common.set-assembly-attribute-values">
184 <property overwrite="false" name="assembly.is-cls-compliant" value="true" />
185 <property overwrite="false" name="assembly.is-com-visible" value="false" />
186 <property overwrite="false" name="assembly.guid" value="" />
187 <property overwrite="false" name="assembly.allow-partially-trusted-callers" value="false" />
188 <property overwrite="false" name="assembly.description" value="" />
189 <property overwrite="false" name="assembly.product" value="${project::get-name()}" />
190 <property overwrite="false" name="assembly.company" value="${project.company}" />
191 <property overwrite="false" name="assembly.title" value="${project::get-name()} for ${framework::get-description(framework::get-target-framework())}" />
192 <property overwrite="false" name="assembly.version" value="${project.major}.${project.minor}.${project.build}.0" />
193 <property overwrite="false" name="assembly.version.informational" value="${assembly.major}.${assembly.minor}.${assembly.build}.${svn.revision}" />
194 <property overwrite="false" name="assembly.copyright" value="Castle Project, original author or authors" />
195 <property overwrite="false" name="assembly.keyfile" value="${key.file}" />
196 <property overwrite="false" name="assembly.sign" value="${sign}" />
199 <target name="common.generate-assemblyinfo"
200 depends="common.init common.set-assembly-attribute-values"
201 description="Generate AssemblyInfo.cs using assembly.* properties."
203 <property name="assemblyinfo.cs" value="${path::combine(src.dir,'AssemblyInfo.cs')}" />
204 <attrib file="${assemblyinfo.cs}" readonly="false" />
205 <asminfo output="${assemblyinfo.cs}" language="CSharp">
207 <import namespace="System" />
208 <import namespace="System.Reflection" />
209 <import namespace="System.Runtime.CompilerServices" />
210 <import namespace="System.Runtime.InteropServices" />
211 <import namespace="System.Security" if="${assembly.allow-partially-trusted-callers}" />
214 <attribute type="CLSCompliantAttribute" value="${assembly.is-cls-compliant}" />
215 <attribute type="ComVisibleAttribute" value="${assembly.is-com-visible}" />
216 <attribute type="GuidAttribute" value="${assembly.guid}" if="${assembly.guid != ''}" />
217 <attribute type="AssemblyTitleAttribute" value="${assembly.title}" />
218 <attribute type="AssemblyDescriptionAttribute" value="${assembly.description}" />
219 <attribute type="AssemblyCompanyAttribute" value="${assembly.company}" />
220 <attribute type="AssemblyProductAttribute" value="${assembly.product}" />
221 <attribute type="AssemblyCopyrightAttribute" value="${assembly.copyright}" />
222 <attribute type="AssemblyVersionAttribute" value="${assembly.version}" />
223 <attribute type="AssemblyInformationalVersionAttribute" value="${assembly.version.informational}" />
224 <attribute type="AssemblyFileVersionAttribute" value="${assembly.version}" />
225 <attribute type="AssemblyDelaySignAttribute" value="false" />
227 <!-- For some reason, NAnt doesn't detect that APTCA has a public no-argument constructor -->
228 <attribute asis="true" type="AllowPartiallyTrustedCallersAttribute" if="${assembly.allow-partially-trusted-callers}" />
231 <if test="${assembly.sign}" >
232 <echo append="true" file="${assemblyinfo.cs}">#if !DOTNET2</echo>
233 <echo append="true" file="${assemblyinfo.cs}">[assembly: AssemblyKeyFileAttribute(@"${path::get-full-path(assembly.keyfile)}")]</echo>
234 <echo append="true" file="${assemblyinfo.cs}">#endif</echo>
238 <target name="common.assemblyinfo">
240 <nant target="generate-assemblyinfo">
241 <buildfiles refid="buildfiles.all" />
246 <target name="common.run-tests"
247 description="Run NUnit tests">
249 <if test="${common.run-tests}">
250 <call target="common.find-nunit" />
252 <echo message="Running tests in '${project::get-name()}'" />
254 <!-- Use nunit-console.exe if found, otherwise fall back to nunit2 task -->
255 <exec if="${nunit.found}"
256 program="${nunit-console}"
257 workingdir="${build.dir}"
258 commandline="${build.dir}\${project::get-name()}.dll /xml:${testresults.dir}/${project::get-name()}.dll-results.xml /config=${build.dir}\${project::get-name()}.dll.config /nologo"
261 <nunit2 unless="${nunit.found}">
266 outputdir="${testresults.dir}"
269 assemblyname="${build.dir}\${project::get-name()}.dll"
270 appconfig="${build.dir}\${project::get-name()}.dll.config" />
273 <if test="${not common.run-tests}">
274 <echo message="Tests are disabled for '${project::get-name()}'" />
279 <target name="common.run-database-tests"
280 depends="common.put-connection-settings-into-app-config common.run-tests common.remove-connection-settings-from-app-config" />
282 <target name="common.put-connection-settings-into-app-config">
284 <property name="app.config" value="${build.dir}\${project::get-name()}.dll.config" />
286 <!-- make sure the config file is writable -->
287 <attrib file="${app.config}" readonly="false" />
290 Tell nhibernate how to connect to the test database.
294 xpath="/configuration/nhibernate/add[@key='hibernate.dialect']/@value"
295 value="${nhibernate.dialect}"
299 xpath="/configuration/nhibernate/add[@key='hibernate.connection.driver_class']/@value"
300 value="${nhibernate.connection.driver_class}"
304 xpath="/configuration/nhibernate/add[@key='hibernate.connection.connection_string']/@value"
305 value="${nhibernate.connection.connection_string}"
309 <target name="common.remove-connection-settings-from-app-config">
310 <property name="app.config" value="${build.dir}\${project::get-name()}.dll.config" />
314 xpath="/configuration/nhibernate/add[@key='hibernate.connection.connection_string']/@value"
315 value="conn string here"