2 <project name=
"NUnit" default=
"build" basedir=
".">
4 This build file will build NUnit for any of the supported
5 runtimes which are actually installed.
9 nant net-1.1 release build
15 net-1.0 Microsoft .NET version 1.0
16 net-1.1 Microsoft .NET version 1.1
17 mono-1.0 Mono version 1.0 (or installed version)
19 Debug and release versions of each of these may be built
23 Default is to build the debug version for .NET 1.1. This
24 may be changed by setting the default properties below.
28 1. Currently, the .NET 1.0 builds of nunit-gui cannot be
29 run successfully. This is because the resource files
30 specify the use of .NET 1.1. This will be fixed in a
33 2. In order to build cpp-sample for either version of .NET,
34 the correct version of cl.exe must be found on the path.
35 This is a limitation of the NAnt <cl> task.
39 <!-- Global settings and defaults -->
40 <property name=
"project.build.dir" value=
"${nant.project.basedir}\build"/>
41 <property name=
"project.package.dir" value=
"${nant.project.basedir}\package"/>
43 <!-- List supported frameworks and flag which ones are available -->
44 <property name=
"frameworks" value=
"net-1.0,net-1.1,mono-1.0"/>
45 <available type=
"Framework" resource=
"net-1.0" property=
"framework.available.net-1.0" />
46 <available type=
"Framework" resource=
"net-1.1" property=
"framework.available.net-1.1" />
47 <available type=
"Framework" resource=
"mono-1.0" property=
"framework.available.mono-1.0" />
49 <!-- Set up default build and runtime configuration -->
50 <property name=
"build.config" value=
"debug"/>
51 <property name=
"build.clean" value=
"false"/>
52 <property name=
"runtime.config" value=
"net"/>
53 <property name=
"runtime.version" value=
"1.1"/>
55 <!-- Get Visual Studio locations from registry if this is a win32 machine -->
56 <if test=
"${platform::is-win32()}">
57 <readregistry property=
"vs.2002.path" key=
"Software\Microsoft\VisualStudio\7.0\InstallDir" hive=
"LocalMachine" />
58 <readregistry property=
"vs.2003.path" key=
"Software\Microsoft\VisualStudio\7.1\InstallDir" hive=
"LocalMachine" />
61 <!-- Set up version for packaging (override as needed) -->
62 <property name=
"package.version" value=
"2.1.91"/>
63 <!-- Root of the package file name -->
64 <property name=
"package.name" value=
"${nant.project.name}-${package.version}"/>
65 <!-- Package directory - will effect top level directory name in zips -->
66 <property name=
"package.dir" value=
"${project.package.dir}/${package.name}"/>
68 <!-- Command-line build configurations -->
69 <target name=
"debug" description=
"Set config to debug">
70 <call target=
"set-debug-build-config" />
73 <target name=
"release" description=
"Set config to release">
74 <call target=
"set-release-build-config" />
77 <target name=
"clean" description=
"Set flag to perform clean builds">
78 <property name=
"build.clean" value=
"true"/>
81 <!-- Command-line runtime configurations -->
82 <target name=
"net" description=
"Set runtime to .NET 1.1">
83 <call target=
"set-net-1.1-runtime-config"/>
86 <target name=
"net-1.0" description=
"Set runtime to .NET 1.0">
87 <call target=
"set-net-1.0-runtime-config"/>
90 <target name=
"net-1.1" description=
"Set runtime to .NET 1.1">
91 <call target=
"set-net-1.1-runtime-config"/>
94 <target name=
"mono" description=
"Set runtime to Mono">
95 <call target=
"set-mono-1.0-runtime-config"/>
98 <target name=
"mono-1.0" description=
"Set runtime to Mono">
99 <call target=
"set-mono-1.0-runtime-config"/>
102 <!-- Clean directories -->
103 <target name=
"clean-build-dir" depends=
"set-build-dir">
104 <delete dir=
"${build.dir}" if=
"${directory::exists( build.dir )}"/>
107 <target name=
"clean-package-dir" depends=
"set-package-config">
108 <delete dir=
"${package.dir}" if=
"${directory::exists( package.dir )}"/>
111 <!-- Targets that operate on all configs and runtimes -->
112 <target name=
"clean-all" description=
"Erase all build directories">
113 <delete dir=
"${project.build.dir}" if=
"${directory::exists( project.build.dir )}"/>
116 <target name=
"build-all"
117 description=
"Build all runtime versions in both debug and release">
118 <call target=
"set-debug-build-config"/>
119 <call target=
"build-each"/>
120 <call target=
"set-release-build-config"/>
121 <call target=
"build-each"/>
124 <target name=
"test-all"
125 description=
"Test all versions in both debug and release">
126 <call target=
"set-debug-build-config"/>
127 <call target=
"test-each"/>
128 <call target=
"set-release-build-config"/>
129 <call target=
"test-each"/>
132 <!-- Create standard packages for distribution - Note that this
133 target has different semantics from the other -all targets -->
134 <target name=
"package-all"
135 description=
"Create all the packages we normally distribute.">
136 <call target=
"package-src"/>
138 <call target=
"set-release-build-config"/>
139 <call target=
"package-each-zip"/>
141 <if test=
"${platform::is-win32()}">
142 <call target=
"set-net-1.1-runtime-config"/>
143 <call target=
"set-release-build-config"/>
145 <call target=
"package-msi"/>
149 <!-- Targets that operate on both debug and release -->
150 <target name=
"build-all-configs"
151 description=
"Build selected runtime version in both debug and release">
152 <call target=
"set-debug-build-config"/>
153 <call target=
"set-runtime-config"/>
154 <call target=
"build"/>
155 <call target=
"set-release-build-config"/>
156 <call target=
"set-runtime-config"/>
157 <call target=
"build"/>
160 <target name=
"test-all-configs"
161 description=
"Test debug and release for the selected runtime version">
162 <call target=
"set-debug-build-config"/>
163 <call target=
"set-runtime-config"/>
164 <call target=
"test"/>
165 <call target=
"set-release-build-config"/>
166 <call target=
"set-runtime-config"/>
167 <call target=
"test"/>
170 <!-- Targets that operate on each available runtime -->
171 <target name=
"build-each"
172 description=
"Build for each available runtime">
173 <foreach item=
"String" delim=
"," property=
"framework" in=
"${frameworks}">
174 <if test=
"${framework::exists( framework )}">
175 <call target=
"set-${framework}-runtime-config"/>
176 <call target=
"build"/>
181 <target name=
"test-each"
182 description=
"Test under each available runtime">
183 <foreach item=
"String" delim=
"," property=
"framework" in=
"${frameworks}">
184 <if test=
"${framework::exists( framework )}">
185 <call target=
"set-${framework}-runtime-config"/>
186 <call target=
"test" />
191 <target name=
"package-each-zip"
192 description=
"Create zip package for each available runtime">
193 <foreach item=
"String" delim=
"," property=
"framework" in=
"${frameworks}">
194 <if test=
"${framework::exists( framework )}">
195 <call target=
"set-${framework}-runtime-config"/>
196 <call target=
"package-zip" />
201 <target name=
"package-each-msi"
202 description=
"Create msi package for each win32 runtime">
204 <fail message=
"MSI can only be built on the Win32 platform" unless=
"${platform::is-win32()}"/>
206 <foreach item=
"String" delim=
"," property=
"framework" in=
"${frameworks}">
207 <if test=
"${framework::exists( framework )}">
208 <call target=
"set-${framework}-runtime-config"/>
209 <if test=
"${build.win32}">
210 <call target=
"package-msi" />
217 <!-- Targets that perform builds -->
218 <target name=
"build" depends=
"set-build-dir"
219 description=
"Build NUnit for a single runtime version and config">
221 <echo message=
"* Starting ${runtime.config} ${runtime.version} ${build.config} build"/>
224 <!-- Clean the build directory if this is a clean build -->
225 <call target=
"clean-build-dir" if=
"${build.clean}"/>
227 <!-- Create the build directory -->
228 <mkdir dir=
"${build.dir}/bin"/>
230 <!-- Copy key file to the correct relative location -->
231 <copy file=
"nunit.key" todir=
"${project.build.dir}"/>
233 <!-- Build everything except the samples -->
234 <nant buildfile=
"framework\nunit.framework.build" target=
"build"/>
235 <nant buildfile=
"core\nunit.core.build" target=
"build"/>
236 <nant buildfile=
"extensions\nunit.extensions.build" target=
"build"/>
237 <nant buildfile=
"util\nunit.util.build" target=
"build"/>
238 <nant buildfile=
"nunit-console\nunit-console.build" target=
"build"/>
239 <nant buildfile=
"mocks\nunit.mocks.build" target=
"build"/>
241 <!-- Build Win32-only projects -->
242 <if test=
"${build.win32}">
243 <nant buildfile=
"uikit\nunit.uikit.build" target=
"build"/>
244 <nant buildfile=
"nunit-gui\nunit-gui.build" target=
"build"/>
247 <!-- Tests need uikit, so build them last -->
248 <nant buildfile=
"tests\tests.build" target=
"build"/>
251 <!-- Build sample programs -->
252 <target name=
"samples" depends=
"build" description=
"Build sample programs">
253 <nant buildfile=
"samples\samples.build" target=
"build"/>
256 <target name=
"build-msi" depends=
"set-build-dir,set-package-config"
257 description=
"Build msi file for installation on Windows systems">
259 <fail message=
"MSI can only be built on the Win32 platform" unless=
"${platform::is-win32()}"/>
260 <fail message=
"MSI can only be built for a Win32 runtime" unless=
"${platform::is-win32()}"/>
263 <echo message=
"* Building msi for ${runtime.config} ${runtime.version} ${build.config}"/>
266 <delete file=
"msi.txt" if=
"${file::exists( 'msi.txt' )}"/>
268 <call target=
"build-${runtime.config}-${runtime.version}-msi"/>
270 <echo message=
"* Build complete - output saved as msi.txt"/>
274 <target name=
"build-net-1.0-msi">
276 <fail message=
"Property vs.2002.path not set" unless=
"${property::exists( 'vs.2002.path' )}"/>
278 <exec program=
"${vs.2002.path}\devenv.exe"
279 commandline=
"nunit.sln /build ${build.config} /project install /out msi.txt"/>
283 <target name=
"build-net-1.1-msi">
285 <fail message=
"Property vs.2003.path not set" unless=
"${property::exists( 'vs.2003.path' )}"/>
287 <exec program=
"${vs.2003.path}\devenv.exe"
288 commandline=
"nunit.sln /build ${build.config} /project install /out msi.txt"/>
292 <!-- Targets for running tests -->
293 <target name=
"test" depends=
"build"
294 description=
"Run tests for a build using console runner">
297 <echo message=
"* Starting ${runtime.config} ${runtime.version} ${build.config} test run"/>
300 <!-- We use exec rather than the nunit2 task because we are testing
301 a new build of NUnit which is likely not to be included in the Nant build -->
302 <exec basedir=
"${build.dir}/bin"
303 workingdir=
"${build.dir}/bin"
304 program=
"nunit-console.exe"
305 commandline=
"nunit.tests.dll" />
309 <target name=
"nunit2-test"
310 description=
"Run tests for a build using console runner">
312 <echo message=
"* Starting ${runtime.config} ${runtime.version} ${build.config} test run"/>
316 <formatter type=
"Plain"/>
317 <test assemblyname=
"${build.dir}/bin/nunit.tests.dll"/>
321 <target name=
"timing-test" depends=
"build"
322 description=
"Run timing tests (long)">
324 <echo message=
"* Starting ${runtime.config} ${runtime.version} ${build.config} timing tests"/>
326 <echo message=
"* WARNING: Test may take some time to run"/>
329 <exec basedir=
"${build.dir}/bin" workingdir=
"${build.dir}/bin" program=
"nunit-console.exe" commandline=
"timing-tests.dll"/>
332 <target name=
"gui-test" depends=
"build"
333 description=
"Run tests for a build using gui runner">
335 <ifnot test=
"${nant.platform.win32}">
336 <fail message=
"NUnit-gui is only available on Win32"/>
339 <ifnot test=
"${build.win32}">
340 <fail message=
"NUnit-gui is only available for Win32"/>
344 <echo message=
"* Starting ${runtime.config} ${runtime.version} ${build.config} gui test run"/>
347 <exec basedir=
"${build.dir}/bin" workingdir=
"${build.dir}/bin" program=
"nunit-gui.exe" commandline=
"nunit.tests.dll"/>
350 <!-- Targets for packaging the NUnit distribution -->
351 <target name=
"package-zip" depends=
"set-package-config" description=
"Create distribution package">
353 <!-- Perform a build -->
354 <call target=
"build"/>
356 <!-- Copy top level files -->
357 <copy file=
"nunit-gui/logo.ico" tofile=
"${build.dir}/logo.ico"/>
358 <copy file=
"license.rtf" tofile=
"${build.dir}/license.rtf"/>
360 <!-- Copy source files that build doesn't copy -->
361 <copy todir=
"${build.dir}/src">
362 <fileset basedir=
".">
363 <includes name=
"nunit.build"/>
364 <includes name=
"nunit.sln"/>
365 <includes name=
"nunit.key"/>
366 <includes name=
"nunit20under21.config"/>
367 <includes name=
"install/install.vdproj"/>
371 <!-- Samples are not built, so let them copy themselves -->
372 <nant buildfile=
"samples/samples.build" target=
"copy-all"/>
375 <call target=
"copy-docs"/>
377 <!-- Remove any temporary output files produced by tests
378 from the build directory - temporary fix -->
381 <includes name=
"temp*.xml"/>
385 <!-- Re-copy everything to our package dir - this is so
386 we get a single top level directory called NUNit-x.x.x -->
387 <call target=
"clean-package-dir"/>
388 <mkdir dir=
"${package.dir}"/>
389 <copy todir=
"${package.dir}">
390 <fileset basedir=
"${build.dir}">
391 <includes name=
"**"/>
395 <!-- Create the zip file -->
396 <zip zipfile=
"${project.package.dir}/${zip.file.name}" ziplevel=
"9">
397 <fileset basedir=
"${package.dir}">
398 <includes name=
"**"/>
403 <target name=
"package-src" depends=
"clean-package-dir"
404 description=
"Create full source package for developer use">
406 <!-- Get source files into the package dir directly -->
407 <property name=
"src.dir" value=
"${package.dir}"/>
408 <mkdir dir=
"${src.dir}"/>
409 <call target=
"copy-src"/>
411 <!-- Get docs into the doc subdirectory of the package dir -->
412 <property name=
"doc.dir" value=
"${package.dir}/doc"/>
413 <call target=
"copy-docs"/>
415 <!-- Create the zip file -->
416 <zip zipfile=
"${project.package.dir}/${zipped.src.file.name}" ziplevel=
"9">
417 <fileset basedir=
"${package.dir}">
418 <includes name=
"**"/>
423 <target name=
"package-msi" depends=
"build-msi,set-package-config"
424 description=
"Build msi file and deploy it to the package dir">
426 <copy file=
"install\${build.config}\${msi.file.name}" tofile=
"${project.package.dir}/${msi.file.name}"/>
430 <target name=
"copy-docs">
431 <mkdir dir=
"${doc.dir}"/>
432 <copy todir=
"${doc.dir}">
433 <fileset basedir=
"doc">
434 <includes name=
"ReleaseNotes.txt"/>
435 <includes name=
"ChangeLog.txt"/>
436 <includes name=
"*.html"/>
437 <includes name=
"css/*"/>
438 <includes name=
"files/*"/>
439 <includes name=
"img/*"/>
444 <target name=
"copy-src">
445 <mkdir dir=
"${src.dir}"/>
447 <!-- Copy top level src files and install project -->
448 <copy todir=
"${src.dir}">
449 <fileset basedir=
".">
450 <includes name=
"license.rtf"/>
451 <includes name=
"nunit.build"/>
452 <includes name=
"nunit.sln"/>
453 <includes name=
"nunit.key"/>
454 <includes name=
"nunit20under21.config"/>
455 <includes name=
"install/install.vdproj"/>
459 <!-- Copy individual projects -->
460 <nant buildfile=
"framework\nunit.framework.build" target=
"copy"/>
461 <nant buildfile=
"core\nunit.core.build" target=
"copy"/>
462 <nant buildfile=
"extensions\nunit.extensions.build" target=
"copy"/>
463 <nant buildfile=
"util\nunit.util.build" target=
"copy"/>
464 <nant buildfile=
"nunit-console\nunit-console.build" target=
"copy"/>
465 <nant buildfile=
"mocks\nunit.mocks.build" target=
"copy"/>
466 <nant buildfile=
"tests\tests.build" target=
"copy-all"/>
467 <nant buildfile=
"samples\samples.build" target=
"copy-all"/>
469 <!-- Copy win32-only projects -->
470 <if test=
"${build.win32}">
471 <nant buildfile=
"uikit\nunit.uikit.build" target=
"copy"/>
472 <nant buildfile=
"nunit-gui\nunit-gui.build" target=
"copy"/>
476 <!-- Register core and framework in the gac -->
477 <target name=
"add-to-gac" depends=
"build">
478 <exec program=
"${nant.settings.currentframework.sdkdirectory}/gacutil.exe"
479 commandline=
"/i ${build.dir}/bin/nunit.framework.dll"/>
480 <echo message=
"The assembly nunit.framework was added to the GAC"/>
482 <exec program=
"${nant.settings.currentframework.sdkdirectory}/gacutil.exe"
483 commandline=
"/i ${build.dir}/bin/nunit.core.dll"/>
484 <echo message=
"The assembly nunit.core was added to the GAC"/>
487 <!-- Set up build configuration -->
489 <target name=
"set-build-config">
490 <call target=
"set-${build.config}-build-config"/>
493 <target name=
"set-debug-build-config">
494 <property name=
"build.config" value=
"debug"/>
495 <property name=
"build.debug" value=
"true"/>
496 <property name=
"build.defines.csc" value=
"DEBUG,TRACE" readonly=
"false" />
497 <property name=
"build.defines.jsc" value=
"DEBUG,TRACE" readonly=
"false" />
498 <property name=
"build.defines.vbc" value=
"DEBUG=True,TRACE=True" readonly=
"false" />
499 <property name=
"build.defines.vjc" value=
"DEBUG,TRACE" readonly=
"false" />
500 <property name=
"build.defines.cl" value=
"/D _DEBUG" readonly=
"false" />
501 <property name=
"zip.build.suffix" value=
"-dbg"/>
502 <property name=
"msi.build.suffix" value=
"-dbg"/>
505 <target name=
"set-release-build-config">
506 <property name=
"build.config" value=
"release"/>
507 <property name=
"build.debug" value=
"false"/>
508 <property name=
"build.defines.csc" value=
"TRACE,STRONG" readonly=
"false" />
509 <property name=
"build.defines.jsc" value=
"TRACE,STRONG" readonly=
"false" />
510 <property name=
"build.defines.vbc" value=
"TRACE=True,STRONG=True" readonly=
"false" />
511 <property name=
"build.defines.vjc" value=
"TRACE,STRONG" readonly=
"false" />
512 <property name=
"build.defines.cl" value=
"/D STRONG" readonly=
"false" />
513 <property name=
"zip.build.suffix" value=
""/>
514 <property name=
"msi.build.suffix" value=
""/>
517 <!-- Set up runtime configuration -->
519 <target name=
"set-runtime-config">
520 <call target=
"set-${runtime.config}-${runtime.version}-runtime-config"/>
523 <target name=
"set-net-1.0-runtime-config">
524 <property name=
"runtime.config" value=
"net"/>
525 <property name=
"runtime.version" value=
"1.0"/>
526 <property name=
"build.mono" value=
"false"/>
527 <property name=
"build.win32" value=
"true"/>
528 <property name=
"nant.settings.currentframework" value=
"net-1.0"/>
529 <property name=
"runtime.defines.csc" value=
"NET,NET_1_0"/>
530 <property name=
"runtime.defines.jsc" value=
"NET,NET_1_0"/>
531 <property name=
"runtime.defines.vbc" value=
"NET=True,NET_1_0=True"/>
532 <property name=
"runtime.defines.vjc" value=
"NET,NET_1_0"/>
533 <property name=
"runtime.defines.cl" value=
"/D NET /D NET_1_0"/>
534 <property name=
"zip.runtime.suffix" value=
"-net-1.0"/>
535 <property name=
"msi.runtime.suffix" value=
"-net-1.0"/>
538 <target name=
"set-net-1.1-runtime-config">
539 <property name=
"runtime.config" value=
"net"/>
540 <property name=
"runtime.version" value=
"1.1"/>
541 <property name=
"build.mono" value=
"false"/>
542 <property name=
"build.win32" value=
"true"/>
543 <property name=
"nant.settings.currentframework" value=
"net-1.1"/>
544 <property name=
"runtime.defines.csc" value=
"NET,NET_1_1"/>
545 <property name=
"runtime.defines.jsc" value=
"NET,NET_1_1"/>
546 <property name=
"runtime.defines.vbc" value=
"NET=True,NET_1_1=True"/>
547 <property name=
"runtime.defines.vjc" value=
"NET,NET_1_1"/>
548 <property name=
"runtime.defines.cl" value=
"/D NET /D NET_1_1"/>
549 <property name=
"zip.runtime.suffix" value=
"-net-1.1"/>
550 <!-- no suffix for the msi - we can only do it for 1.1 anyway -->
551 <property name=
"msi.runtime.suffix" value=
""/>
554 <target name=
"set-mono-1.0-runtime-config">
555 <property name=
"runtime.config" value=
"mono"/>
556 <property name=
"runtime.version" value=
"1.0"/>
557 <property name=
"build.mono" value=
"true"/>
558 <property name=
"build.win32" value=
"false"/>
559 <property name=
"nant.settings.currentframework" value=
"mono-1.0"/>
560 <property name=
"runtime.defines.csc" value=
"MONO,MONO_1_0"/>
561 <property name=
"runtime.defines.jsc" value=
"MONO,MONO_1_0"/>
562 <property name=
"runtime.defines.vbc" value=
"MONO=True,MONO_1_0=True"/>
563 <property name=
"runtime.defines.vjc" value=
"MONO,MONO_1_0"/>
564 <property name=
"runtime.defines.cl" value=
"/D MONO /D MONO_1_0"/>
565 <property name=
"zip.runtime.suffix" value=
"-mono"/>
566 <property name=
"msi.runtime.suffix" value=
"-mono"/>
569 <!-- Set up the build directory -->
570 <target name=
"set-build-dir" depends=
"set-build-config,set-runtime-config">
571 <property name=
"build.dir" value=
"${project.build.dir}/${runtime.config}-${runtime.version}/${build.config}"/>
572 <property name=
"bin.dir" value=
"${build.dir}/bin"/>
573 <property name=
"src.dir" value=
"${build.dir}/src"/>
574 <property name=
"doc.dir" value=
"${build.dir}/doc"/>
577 <!-- Setup the package configuration info -->
578 <target name=
"set-package-config" depends=
"set-build-config,set-runtime-config">
579 <property name=
"zip.file.name" value=
"${package.name}${zip.runtime.suffix}${zip.build.suffix}.zip"/>
580 <property name=
"msi.file.name" value=
"${package.name}${msi.runtime.suffix}${msi.build.suffix}.msi"/>
581 <property name=
"zipped.src.file.name" value=
"${package.name}-src.zip"/>
584 <!-- Dump configuration settings for debugging -->
586 <target name=
"dump-settings" depends=
"set-build-dir,set-package-config">
587 <echo>Configuration
</echo>
588 <echo> Config: ${build.config}
</echo>
589 <echo> Runtime: ${runtime.config}-${runtime.version}
</echo>
590 <echo> Version: ${package.version}
</echo>
591 <echo> Package name: ${package.name}
</echo>
592 <echo> Zip file: ${zip.file.name}
</echo>
593 <echo> Msi file: ${msi.file.name}
</echo>
594 <echo> Source zip: ${zipped.src.file.name}
</echo>
596 <echo>Project Directories
</echo>
597 <echo> Base: ${nant.project.basedir}
</echo>
598 <echo> Build: ${project.build.dir}
</echo>
599 <echo> Package: ${project.package.dir}
</echo>
601 <echo>Current Directories
</echo>
602 <echo> Build: ${build.dir}
</echo>
603 <echo> Package: ${package.dir}
</echo>
605 <echo>System Directories
</echo>
606 <echo> Framework: ${nant.settings.currentframework.frameworkdirectory}
</echo>
607 <echo> SDK: ${nant.settings.currentframework.sdkdirectory}
</echo>
608 <echo> VS
2002: ${vs
.2002.path}
</echo>
609 <echo> VS
2003: ${vs
.2003.path}
</echo>