How to show TestReport when NUnit is called from MsBuild using Exec command in TC 9.0?

Hello support,

I am using James Kovacs approach using TeamCity in my project.

It allows using the same build script and its targets:

    • from PowerShell on developer machine before code commit
  • from TeamCity on independent server after code was commit to source control

One of the topic is to run the TASK from build script using MsBuild runner.  The TASK executes NUnit and TC shows Test report after test execution.

Build script code


    <NUnit Include=".\thirdparty\tools\NUnit\nunit-console.exe"/>

    <TestAssembly Include=".\buildartifacts\HelloCI.Web.UnitTest.dll"/>

    <TestResult Include=".\buildartifacts\TestResults.xml"/>


<Target Name="Compile" DependsOnTargets ="Init" >

    <MSBuild Projects="@(SolutionFile)" Targets ="Rebuild" Properties="OutDir=%(Buildartifacts.FullPath);   Configuration=$(Configuration)"/>    


<Target Name="NUnit" DependsOnTargets ="Compile">

      <Exec Command="@(NUnit) @(TestAssembly) /xml=@(TestResult)" />


Team City runner configuration is attached. See TCConf.png

This configuration shows the build and tests were run on independent tab. In TC version 9.0 you ‘ve removed “Run NUnit test” option to independent Runner type that can be included as a step to build process.

This approach is not suitable for me because I can’t use it from PowerShell.

There is another case to use NUnit tast inside build script.

<UsingTask TaskName="NUnit" AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)"/>

<Target Name="TCNUnit">

     <NUnit Assemblies="@(TestAssembly)"/>


This approach automatically includes test report to the build result. But I can’t use it from PowerShell. (An error occurred of parsing teamcity_dotnet_nunitlauncher_msbuild_task variable)

So my question is.

How can I use James Kovacs approach, based on NUnit execution using "Exec" command from MsBuild runner in TC version 9.0, to show Test report?

Thank you for your help.



Comment actions Permalink

Unfortunately, I can not help, but I don't understand the advantage of a local build if you have the option of a remote build:

Comment actions Permalink


Thank you for reply.

Local build has the following  advantages:
1. It does not require network connection. There is the cases when internet/intranet connection is lose.
2. It is done on developer machine which is expected because it is development phase and we don't need to check any interraction/integration with working code on independent server.
3. Approache based on MsBuild+Exec excution does not reuqire to know TC and its API.
So during agile zero iteration we can devide build machine configuration on two sub tasks and assign to different persons: Task 1. TC configuration. Task 2.  Develop build script.
4. All test, code coverage reports XML, HTML are created locally which is suitable for developer.  
5.TC licence could be suspended because of different reasons, so some time will be needed to update the licence. Meanwhile developers could continue development.

TC 9.0 has much more Web(UI) tools to configure CI process than older TeamCity version.
1. But this tools are run on server side.
2. As I understood TC 9.0 brought some limitations to manual configuration in build script because it can't be reflected by TC server.



Please sign in to leave a comment.