NAnt
note
Starting with TeamCity 2024.07, the NAnt runner is deprecated. It remains bundled for compatibility but will be removed in future releases. We recommend switching to the .NET runner for testing .NET and .NET Framework applications.
To continue using the NAnt runner after it is unbundled, you can download a separate plugin from the JetBrains Marketplace.
The NAnt build runner allows using NAnt build files.
TeamCity supports NAnt starting from version 0.85.
note
The TeamCity NAnt runner requires .NET Framework or Mono installed on the build agent.
The TeamCity NAnt runner includes a task called msbuild
that allows NAnt to start MSBuild scripts. TeamCity msbuild
task for NAnt has the same set of attributes as the NAntContrib package msbuild
task. The MSBuild build processes started by NAnt will behave exactly as if they were launched by TeamCity MSBuild/SLN2005 build runner (that is NUnit
and/or NUnitTeamCity
MSBuild tasks will be added to build scripts and logs and error reports will be sent directly to the build server).
note
msbuild
task for NAnt makes all build configuration system properties available inside MSBuild script. Note, all property names will have.
replaced with_
.
To disable this, setfalse
toset-teamcity-properties
attribute of the task.
By default, NAnt msbuild
task checks for current value of NAnt target-framework property to select MSBuild runtime version.
This parameter could be overriden by setting teamcity_dotnet_tools_version
project property with required .NET Framework version, i.e. "4.0".
...
<!-- this property enables MSBuild 4.0 -->
<property name="teamcity_dotnet_tools_version" value="4.0"/>
<msbuild project="SimpleEcho.v40.proj">
...
</msbuild>
...
note
To pass properties to MSBuild, use the
property
tag instead of the explicit properties definition in the command line.
To test all the assemblies without halting on first failed test use:
<target name="build">
<nunit2 verbose="true" haltonfailure="false" failonerror="true" failonfailureatend="true">
<formatter type="Plain" />
<test haltonfailure="false">
<assemblies>
<include name="dll1.dll" />
<include name="dll2.dll" />
</assemblies>
</test>
</nunit2>
</target>
note
The
failonfailureatend
attribute is not defined in the originalNUnit2
task from NAnt. Note that this attribute will be ignored if thehaltonfailure
attribute is set totrue
for either thenunit2
element or thetest
element.
Below you can find reference information about NAnt Build Runner fields.
Option | Description |
---|---|
Path to a build file | Specify path relative to the Build Checkout Directory. |
Build file content | Select the option, if you want to use a different build script than the one listed in the settings of the build file. When the option is enabled, you have to type the build script in the text area. |
Targets | Specify the names of build targets defined by the build script, separated by spaces. The available targets can be viewed in the Web UI by clicking the icon next to the field and added by checking the appropriate boxes. |
Working directory | Specify the path to the Build Working Directory. By default, the build working directory is set to the same path as the build checkout directory. |
NAnt home | Enter a path to the
|
Target framework | Sets
|
Command line parameters | Specify any additional parameters for
|
Reduce test failure feedback time | Use following option to instruct TeamCity to run some tests before others. |
Run recently failed tests first | If checked, in the first place TeamCity will run tests failed in previous finished or running builds as well as tests having high failure rate (a so called blinking tests). |
To learn about configuring code coverage options, refer to the Configuring .NET Code Coverage page.
Thanks for your feedback!