Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 91241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:59:57+00:00 2026-05-10T22:59:57+00:00

I am modifying a Nant build script to run some unit tests. I have

  • 0

I am modifying a Nant build script to run some unit tests. I have different targets for locally run tests and tests to be run on team city.

<target name="run-unit-tests">      <property name="test.executable" value="tools\nunit\nunit-console.exe"/>    <call target="do-unit-tests"/> </target>  <target name="run-unit-tests-teamcity">     <property name="test.executable" value="${teamcity.dotnet.nunitlauncher}"/>          <call target="do-unit-tests"/> </target> 

in the target do-unit-tests I set up which test assemblies are run by setting a property and calling for NCover to do a code coverage run as follows:

<target name="do-unit-test">    <property name="test.assemblies" value="MyProject.dll">    <call target="do-unit-test-coverage" /> </target>  <target name="do-unit-test-coverage">    <ncover <!--snip -->            commandLineArgs="${test.args}"    <!--snip-->    </ncover> </target> 

As you can see in the ncover part I need a property called "test.args". This property depends on "test.assemblies"

ie: <property name="test.args" value="${test.assemblies} <!--snip -->" />

test.args needs to be set up differently between the locally run unit test and the one on team city…so I’m trying to figure out how to set this up.

if i put the property for test.args in "do-unit-test" after the property "test.assemblies" I can’t specify one test.args if do-unit-test is called by run-unit-tests and another for run-unit-tests-teamcity.

I’ve been trying to do something like the following in "do-unit-test":

<if test="${target::exists('run-unit-tests-teamcity')}">  <property name="test.args" value="..." /> </if> 

but obviously that doesn’t work because the target will always exist.

What I’d like then is to test if my current target do-unit-test has been called by run-unit-tests-teamcity

Is this possible? I can’t see it in the Nant documentation? Since its not there it either means that it will be a feature in the future or that I’m not understanding how things are specified in a Nant build script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:59:57+00:00Added an answer on May 10, 2026 at 10:59 pm

    You can define properties in one target, and use their values in the other… For example, you can define

    <target name='run-unit-tests'>    <property name='test.executable' value='tools\nunit\nunit-console.exe'/>    <property name='test.extratestargs' value='foo,bar,baz'/>    <call target='do-unit-tests'/> </target>  <target name='run-unit-tests-teamcity'>    <property name='test.executable' value='${teamcity.dotnet.nunitlauncher}'/>             <property name='test.extrtestargs' value='foo,baz,quux,xyzzy'/>    <call target='do-unit-tests'/> </target>  <target name='do-unit-test-coverage'>    <property name='test.args' value='${test.assemblies} ${test.extratestargs} <!--snip -->' />    <ncover <!--snip -->            commandLineArgs='${test.args}' >    <!--snip-->    </ncover> </target>   

    Or if you need them to be structured completely differently, not just have some different values, take advantage of the fact that the property substitution is delayed:

     <?xml version="1.0"?>  <project name="nanttest">          <target name="run-unit-tests">            <property name="test.executable" value="tools\nunit\nunit-console.exe"/>            <property name="test.args" value="foo bar -assembly ${test.assemblies} baz" dynamic="true"/>            <call target="do-unit-test"/>         </target>          <target name="run-unit-tests-teamcity">            <property name="test.executable" value="${teamcity.dotnet.nunitlauncher}"/>            <property name="test.args" value="foo,baz,quux /a:${test.assemblies} xyzzy" dynamic="true"/>            <call target="do-unit-test"/>         </target>          <target name="do-unit-test-coverage">            <echo message="test.executable = ${test.executable}, test.args = ${test.args}" />         </target>          <target name="do-unit-test">            <property name="test.assemblies" value="MyProject.dll"/>            <call target="do-unit-test-coverage" />         </target>   </project>  
     user@host:/tmp/anttest$ nant run-unit-tests [...snip...] run-unit-tests: do-unit-test: do-unit-test-coverage:      [echo] test.executable = tools\nunit\nunit-console.exe, test.args = foo bar -assembly MyProject.dll baz BUILD SUCCEEDED Total time: 0 seconds.  user@host:/tmp/anttest$ nant -D:teamcity.dotnet.nunitlauncher=nunitlauncher run-unit-tests-teamcity [...snip...] run-unit-tests-teamcity: do-unit-test: do-unit-test-coverage:      [echo] test.executable = nunitlauncher, test.args = foo,baz,quux /a:MyProject.dll xyzzy BUILD SUCCEEDED Total time: 0 seconds. 

    If you really, really just need to know if you’re running in TeamCity, then this should help:

    <target name='run-unit-tests-teamcity'>    <property name='test.executable' value='${teamcity.dotnet.nunitlauncher}'/>             <property name='running.in.teamcity' value='true'/>    <call target='do-unit-tests'/> </target>  
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using NAnt 0.85 to build a legacy project. The script itself uses the
I'm modifying a tree view of some relationships we have, I've managed (with help)
I am modifying some code and came across a declaration that I am having
We are looking at modifying our build process so that our configuration files are
Modifying Abstract Syntax Trees I would like to be able to build and modify
Modifying a SnapPages theme, meaning I only have access to the CSS stylesheet. I
I'm modifying phpBB's table to have bidirectional relationships for friends. Unfortuntately, people that have
I am modifying an existing app.And there is an issue trying to run ADT
I have multiple threads modifying an stl vector and an stl list. I want
Im modifying a theme in wordpress and would like to have the possibility to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.