Problems with MsBuild 4.0 runner and Nunit

I just upgraded from TC 5.0.1 to 5.1.5 in order to utilize MsBuild 4.0 in order to utilize a Microsoft web deployment build target. Prior to upgrading TC was always executing MSB 2.0 regardless of the MSBuild version setting and I had read in the forums that 5.0.1 did not correctly support those versions of MSB.

Now what I am encountering is that when running with MSB set to 3.5 Nunit tests execute fine but when set to 4.0 I see the following errors in the build log.

(UnitTest target) ->

[14:01:01]: D:\Integration\Checkout\TsrService\TsrService\build.proj(102,5): error :  Could not find the NUnit Project File open command. Please make sure  NUnit is installed.  [D:\Integration\Checkout\TsrService\TsrService\build.proj.teamcity.patch.tcprojx]
[14:01:01]: D:\Integration\Checkout\TsrService\TsrService\build.proj(102,5): error  MSB6004: The specified task executable location "C:\Program Files  (x86)\NUnit-Net-2.0 2.2.7\bin\nunit-console.exe" is invalid.  [D:\Integration\Checkout\TsrService\TsrService\build.proj.teamcity.patch.tcprojx]
[14:01:01]: 0 Warning(s)



Nunit 2.5 is installed on this build server and is located at C:\Program Files (x86)\NUnit 2.5
10 comments
Comment actions Permalink

I reverted my build file and changed setting back to MSB 3.5 and still getting the same error. Interestingly, other builds in the same project using same build file and settings are running fine.

0
Comment actions Permalink

Ok, after restarting the TeamCity service the build ran successfully. I guess there was something cached in the build server project...

I'll wait to get some input from developers before attempting again to change projects Msbuild version from 3.5 to 4.0.

0
Comment actions Permalink

Is anyone else using the 4.0 runner in TC 5.1 and Nunit successfully?

0
Comment actions Permalink

Steven

Please try to run MSBuild 4.0 manually, outside TeamCity. Does it work?

Michael

0
Comment actions Permalink

Yes, it does work outside of TeamCity.

Thanks,
Steve

0
Comment actions Permalink

How do you call NUnit from your build script? Please check the msbuild script section where path to NUnit is calculated.

0
Comment actions Permalink

This is the target that executes the Nunit task. There is no explicit pathing in the script to the Nunit exe. I believe that the path environment variable points to Nunit.

  <Target Name="UnitTest" DependsOnTargets="CompileTest">
    <DirectoryListing DirectoryName="$(TestDir)$(TestBin)" ExtensionFilter="*Test*.$(AssemblyType)">
      <Output TaskParameter="DirectoryFileList" ItemName="TestAssemblies" />
    </DirectoryListing>
    
    <Message Text="==> UNIT TEST - Test Assemblies: %(TestAssemblies.FullPath)" />
    <NUnit Assemblies="@(TestAssemblies)"
          ExcludeCategory="$(categoryExclude)"
          IncludeCategory="$(categoryInclude)"
          DisableShadowCopy="true"/>
  </Target>

0
Comment actions Permalink

I've just got the same error in my lab.
Try to set a path to NUnit explicitly:
<NUnit ToolPath="c:\Programs\NUnit-2.5.9.10348\bin\net-2.0" ... >

Michael

0
Comment actions Permalink

Been on other priorities the last couple of weeks and just got back into this one.

I did get it to run by specifying the ToolPath= attribute on the NUnit task with a caveat though. Along the way I discovered some other things that I thought I would share.

I discovered the "New NUnit Test Settings" section on the "Runner: MSBuild" configuration page and thought I would give this a try first. It actually worked quite well and executed NUnit without having to explicitly specifiy an executable path. The only proble was that it is the last task to run in the build, which, in my case does not meet our needs becuase we have a task to publish a web application after unit test are run sucessfully.

So I went back to running the NUnit task from within the MSBuild script. I then tried to specify an path environment variable env.PATH with the path to NUnit. After doing that, then I received an error for an SVN task stating an invalid command line switch for SVN.

I removed the environment variable from the build and proceeded to put the ToolPath attribute on the Nunit task in the build script. It ran the build successfully on the next attempt, however, the test output was no longer being automatically picked up and reported on in the build. I then configured the "XML Report Processing' setting on the Runner: MSBuild configuration and specified the Nunit output xml file. After doing that all was working again as expected.

0
Comment actions Permalink

Sounds good.

TeamCity provides another NUnit task for running NUnit tests with on-the-fly tests reporting. Please take a look to the related documentation at
http://confluence.jetbrains.net/display/TCD6/NUnit+for+MSBuild

0

Please sign in to leave a comment.