Problems running NUnit tests for .NET 4 TeamCity 5 EAP

Hi

I am using TeamCity 5 EAP and am having difficulty running my NUnit tests.  I consistently get the following error:

NUnit Error: Could not load file or assembly 'MySolution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

My configuration is as follows:

  • Build Runner: MSBuild
  • MSBuild version: Microsoft .NET Framework 4.0


My MSBuild is pretty simple which is:

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask TaskName="NUnit" AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)"/>

  <Target Name="Build">

    <MSBuild Projects="$(teamcity_build_checkoutDir)\MySolution.sln" Properties="Configuration=Release" />

  </Target>

  <Target Name="UnitTests" DependsOnTargets="Build">
    <NUnit Assemblies="$(teamcity_build_checkoutDir)\MySolution\bin\Release\MySolution.dll" />
  </Target>

</Project>



Any help would be appreciated.

Cheers,

Jon
2 comments
Comment actions Permalink

What build was it? Please check you started MSBuild from .NET 4.0.

The error you've shown could mean you are trying to start NUnit running from .NET 2.0.

Try setting 'DEBUG_MODE_KEY' with value 'true' as build configuration property to get more debug information. Please attach the resulting build log.

Thanks!

0
Comment actions Permalink

After some more investigation it appears that I had one of my projects set to Platform Target of x86 instead of Any CPU, which caused the problem.

It was evident because the error message was referring to the assembly under test not the assembly which contained the unit tests.

0

Please sign in to leave a comment.