📄 nunit.build
字号:
<?xml version="1.0"?>
<project name="NUnit" default="build" basedir=".">
<!--
This build file will build NUnit for any of the supported
runtimes which are actually installed.
NOTE: This file uses features that are not available in
NAnt 0.84. It has been tested using the nightly download
nant-0.85-20040707.zip.
Examples of Use:
nant net-1.1 release build
nant build-all
nant clean build
Runtime Support:
net-1.0 Microsoft .NET version 1.0
net-1.1 Microsoft .NET version 1.1
net-2.0 Microsoft .NET version 2.0
mono-1.0 Mono version 1.0 (or installed version)
Debug and release versions of each of these may be built
Default:
Default is to build the debug version for .NET 1.1. This
may be changed by setting the default properties below.
Limitations:
1. Currently, the .NET 1.0 builds of nunit-gui cannot be
run successfully. This is because the resource files
specify the use of .NET 1.1. This will be fixed in a
follow-up release.
2. In order to build cpp-sample for either version of .NET,
the correct version of cl.exe must be found on the path.
This is a limitation of the NAnt <cl> task.
-->
<!-- Global settings and defaults -->
<property name="project.build.dir" value="${nant.project.basedir}\build"/>
<property name="project.package.dir" value="${nant.project.basedir}\package"/>
<!-- List supported frameworks and flag which ones are available -->
<property name="frameworks" value="net-1.0,net-1.1,mono-1.0"/>
<available type="Framework" resource="net-1.0" property="framework.available.net-1.0" />
<available type="Framework" resource="net-1.1" property="framework.available.net-1.1" />
<available type="Framework" resource="mono-1.0" property="framework.available.mono-1.0" />
<!-- Set up default build and runtime configuration -->
<property name="build.config" value="debug"/>
<property name="build.clean" value="false"/>
<property name="runtime.config" value="net"/>
<property name="runtime.version" value="1.1"/>
<!-- Get Visual Studio locations from registry if this is a win32 machine -->
<if test="${platform::is-win32()}">
<readregistry property="vs.2002.path" key="Software\Microsoft\VisualStudio\7.0\InstallDir" hive="LocalMachine" />
<readregistry property="vs.2003.path" key="Software\Microsoft\VisualStudio\7.1\InstallDir" hive="LocalMachine" />
</if>
<!-- Set up version for packaging (override as needed) -->
<property name="package.version" value="2.2.0"/>
<!-- Root of the package file name -->
<property name="package.name" value="${nant.project.name}-${package.version}"/>
<!-- Package directory - will effect top level directory name in zips -->
<property name="package.dir" value="${project.package.dir}/${package.name}"/>
<!-- Command-line build configurations -->
<target name="debug" description="Set config to debug">
<call target="set-debug-build-config" />
</target>
<target name="release" description="Set config to release">
<call target="set-release-build-config" />
</target>
<target name="clean" description="Set flag to perform clean builds">
<property name="build.clean" value="true"/>
</target>
<!-- Command-line runtime configurations -->
<target name="net" description="Set runtime to .NET 1.1">
<call target="set-net-1.1-runtime-config"/>
</target>
<target name="net-1.0" description="Set runtime to .NET 1.0">
<call target="set-net-1.0-runtime-config"/>
</target>
<target name="net-1.1" description="Set runtime to .NET 1.1">
<call target="set-net-1.1-runtime-config"/>
</target>
<target name="net-2.0" description="Set runtime to .NET 2.0">
<call target="set-net-2.0-runtime-config"/>
</target>
<target name="mono" description="Set runtime to Mono">
<call target="set-mono-1.0-runtime-config"/>
</target>
<target name="mono-1.0" description="Set runtime to Mono">
<call target="set-mono-1.0-runtime-config"/>
</target>
<!-- Clean directories -->
<target name="clean-build-dir" depends="set-build-dir">
<delete dir="${build.dir}" if="${directory::exists( build.dir )}"/>
</target>
<target name="clean-package-dir" depends="set-package-config">
<delete dir="${package.dir}" if="${directory::exists( package.dir )}"/>
</target>
<!-- Targets that operate on all configs and runtimes -->
<target name="clean-all" description="Erase all build directories">
<delete dir="${project.build.dir}" if="${directory::exists( project.build.dir )}"/>
</target>
<target name="build-all"
description="Build all runtime versions in both debug and release">
<call target="set-debug-build-config"/>
<call target="build-each"/>
<call target="set-release-build-config"/>
<call target="build-each"/>
</target>
<target name="test-all"
description="Test all versions in both debug and release">
<call target="set-debug-build-config"/>
<call target="test-each"/>
<call target="set-release-build-config"/>
<call target="test-each"/>
</target>
<!-- Create standard packages for distribution - Note that this
target has different semantics from the other -all targets -->
<target name="package-all"
description="Create all the packages we normally distribute.">
<call target="package-src"/>
<call target="set-release-build-config"/>
<call target="package-each-zip"/>
<if test="${platform::is-win32()}">
<call target="set-net-1.1-runtime-config"/>
<call target="set-release-build-config"/>
<call target="package-msi"/>
</if>
</target>
<!-- Targets that operate on both debug and release -->
<target name="build-all-configs"
description="Build selected runtime version in both debug and release">
<call target="set-debug-build-config"/>
<call target="set-runtime-config"/>
<call target="build"/>
<call target="set-release-build-config"/>
<call target="set-runtime-config"/>
<call target="build"/>
</target>
<target name="test-all-configs"
description="Test debug and release for the selected runtime version">
<call target="set-debug-build-config"/>
<call target="set-runtime-config"/>
<call target="test"/>
<call target="set-release-build-config"/>
<call target="set-runtime-config"/>
<call target="test"/>
</target>
<!-- Targets that operate on each available runtime -->
<target name="build-each"
description="Build for each available runtime">
<foreach item="String" delim="," property="framework" in="${frameworks}">
<if test="${framework::exists( framework )}">
<call target="set-${framework}-runtime-config"/>
<call target="build"/>
</if>
</foreach>
</target>
<target name="test-each"
description="Test under each available runtime">
<foreach item="String" delim="," property="framework" in="${frameworks}">
<if test="${framework::exists( framework )}">
<call target="set-${framework}-runtime-config"/>
<call target="test" />
</if>
</foreach>
</target>
<target name="package-each-zip"
description="Create zip package for each available runtime">
<foreach item="String" delim="," property="framework" in="${frameworks}">
<if test="${framework::exists( framework )}">
<call target="set-${framework}-runtime-config"/>
<call target="package-zip" />
</if>
</foreach>
</target>
<target name="package-each-msi"
description="Create msi package for each win32 runtime">
<fail message="MSI can only be built on the Win32 platform" unless="${platform::is-win32()}"/>
<foreach item="String" delim="," property="framework" in="${frameworks}">
<if test="${framework::exists( framework )}">
<call target="set-${framework}-runtime-config"/>
<if test="${build.win32}">
<call target="package-msi" />
</if>
</if>
</foreach>
</target>
<!-- Targets that perform builds -->
<target name="build" depends="set-build-dir"
description="Build NUnit for a single runtime version and config">
<echo message="*"/>
<echo message="* Starting ${runtime.config} ${runtime.version} ${build.config} build"/>
<echo message="*"/>
<!-- Clean the build directory if this is a clean build -->
<call target="clean-build-dir" if="${build.clean}"/>
<!-- Create the build directory -->
<mkdir dir="${build.dir}/bin"/>
<!-- Copy key file to the correct relative location -->
<copy file="nunit.key" todir="${project.build.dir}"/>
<!-- Build everything except the samples -->
<nant buildfile="framework\nunit.framework.build" target="build"/>
<nant buildfile="core\nunit.core.build" target="build"/>
<nant buildfile="extensions\nunit.extensions.build" target="build"/>
<nant buildfile="util\nunit.util.build" target="build"/>
<nant buildfile="nunit-console\nunit-console.build" target="build"/>
<nant buildfile="mocks\nunit.mocks.build" target="build"/>
<!-- Build Win32-only projects -->
<if test="${build.win32}">
<nant buildfile="uikit\nunit.uikit.build" target="build"/>
<nant buildfile="nunit-gui\nunit-gui.build" target="build"/>
<!-- Tests need uikit, so build them last -->
<nant buildfile="tests\tests.build" target="build"/>
</if>
<!-- Tests are not compiling under mono, so they are temporarily moved above -->
</target>
<!-- Build sample programs -->
<target name="samples" depends="build" description="Build sample programs">
<nant buildfile="samples\samples.build" target="build"/>
</target>
<target name="build-msi" depends="set-build-dir,set-package-config"
description="Build msi file for installation on Windows systems">
<fail message="MSI can only be built on the Win32 platform" unless="${platform::is-win32()}"/>
<fail message="MSI can only be built for a Win32 runtime" unless="${platform::is-win32()}"/>
<echo message="*"/>
<echo message="* Building msi for ${runtime.config} ${runtime.version} ${build.config}"/>
<echo message="*"/>
<delete file="msi.txt" if="${file::exists( 'msi.txt' )}"/>
<call target="build-${runtime.config}-${runtime.version}-msi"/>
<echo message="* Build complete - output saved as msi.txt"/>
</target>
<target name="build-net-1.0-msi">
<fail message="Property vs.2002.path not set" unless="${property::exists( 'vs.2002.path' )}"/>
<exec program="${vs.2002.path}\devenv.exe"
commandline="nunit.sln /build ${build.config} /project install /out msi.txt"/>
</target>
<target name="build-net-1.1-msi">
<fail message="Property vs.2003.path not set" unless="${property::exists( 'vs.2003.path' )}"/>
<exec program="${vs.2003.path}\devenv.exe"
commandline="nunit.sln /build ${build.config} /project install /out msi.txt"/>
</target>
<!-- Targets for running tests -->
<target name="test" depends="build"
description="Run tests for a build using console runner">
<echo message="*"/>
<echo message="* Starting ${runtime.config} ${runtime.version} ${build.config} test run"/>
<echo message="*"/>
<!-- We use exec rather than the nunit2 task because we are testing
a new build of NUnit which is likely not to be included in the Nant build -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -