Tuesday 2 November 2010

TeamCity, Nunit, .net sln build - A simple how to

We have installed TeamCity for our CI needs and very nice it is too. However, when we came to get it to run our nUnit tests we found it very hard to find an example of the most simple way to get this working. The TeamCity documentation is not clear at all if you are MSBuild newbies like us.

So, to save you the pain, here is how it works

  • You need to realise first of all that you need to make an MSBuild script which will build your .sln file and also run the nunit tests
  • Then when you configure your project in TeamCity at the Runnner:MSBuild page point the 'Build File Path' to your msbuild file. We checked this msbuild file into subversion.
  • In order to get TeamCity to run the tests this is what the MSBuild file should look like what is shown below
  • Please note that when we put ANY rather than v2.0 in the exec line, we got nunit errors
  • Please also not this is a starting point and we know nothing of MSBuild so I am sure there are many other ways of doing this.... Hope this helps!
<Project DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Debug</Configuration>
</PropertyGroup>
<Target Name="Test" DependsOnTargets="Build">
<Exec Command="$(teamcity_dotnet_nunitlauncher) v2.0 x86 NUnit-2.4.8 D:\PathToMyTestDLL\MyTests.dll" />
</Target>
<Target Name="Build">
<MSBuild Projects="PathToMySolutionFileRelativeToThisMSBuildFile/MySolution.sln"/>
</Target>
</Project>

2 comments:

  1. For any software if its all working well even then it should have a easy to understand guide for the user that help them using it.It makes it complete.

    ReplyDelete
  2. We all appreciate your information. Keep posting these kind of nice blogs.
    phen375 reviews | phen375 weight loss

    ReplyDelete