TeamCity, C# and NUnit - TeamCity borks - why ?

Hi,

Wer'e a group of students doing our B.Sc. project using C#, ASP.NET and we use NUnit for tests.

At the start of the project, we decided to use TeamCity since I have been using it with Java/IntelliJ for some time, and have little trouble there.

However, once it comes to NUnit, TeamCity borks on us at every build. It has (for me) come to the point where I don't have time anymore to try to debug what's happening, so I turn to the community for help.

The error I get is:
: Target "NUnit_TeamCity_generated_670457e5ff2740678b614ed8238a0189" in project "Greinir.Web.sln.teamcity.patch.tcprojx" (1m:17s)
: [Target "NUnit_TeamCity_generated_670457e5ff2740678b614ed8238a0189" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] Failure executing test(s). If you assembly is not built using NUnit version 2.4.6.0, then ensure you have redirected assembly bindings. Consult the documentation of the ]]> task for more information.
: [Target "NUnit_TeamCity_generated_670457e5ff2740678b614ed8238a0189" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] Could not load file or assembly 'nunit.framework, Version=2.2.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

We are using version 2.4.6 of NUnit, but nevertheless, it seems it's always trying to load version 2.2.0.0.

I did have NUnit installed (2.4.6) on the build agent, but reverted (uninstalled 2.4.6) to including the dll's in the project as mentioned in a couple of threads here, to no avail.

Now I'm kind of dead in the water. We can run the NUnit tests manually, but that defeats the purpose of the build server - and we don't get the fancy reports to include in our final report, something we'd promised our mentor.

So I turn to the benevolent community of TeamCity users, crying "HELP" - please :)

13 comments

Hello,

Do you have NUnit.Framework 2.2.0.0 installed in GAC on your build agent?
Do you have NUnit.Framework.dll of version 2.4.6.0 is put to the same folder
as dll's to run tests on.

Actually, TeamCity uses Bundled version of NUnit to run tests with. It
is possible to swith to
NUnit 2.4.6 support from MSBuild runner settings.

Please check the version on NUnit.Framework.dll to be exactly the same
version as used to build test.

BTW. Could you please check the the reference from test assembly to NUnit.Framework,
what version is required there?

For doing those versions check, consinder using .NET Reflector (http://www.aisto.com/roeder/dotnet/)

Eugene Petrenko
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hi,

Wer'e a group of students doing our B.Sc. project using C#, ASP.NET
and we use NUnit for tests.

At the start of the project, we decided to use TeamCity since I have
been using it with Java/IntelliJ for some time, and have little
trouble there.

However, once it comes to NUnit, TeamCity borks on us at every build.
It has (for me) come to the point where I don't have time anymore to
try to debug what's happening, so I turn to the community for help.

The error I get is:

: Target
"NUnit_TeamCity_generated_670457e5ff2740678b614ed8238a0189" in project
"Greinir.Web.sln.teamcity.patch.tcprojx" (1m:17s)

: [Target
"NUnit_TeamCity_generated_670457e5ff2740678b614ed8238a0189" in project
"Greinir.Web.sln.teamcity.patch.tcprojx"] Failure executing test(s).
If you assembly is not built using NUnit version 2.4.6.0, then ensure
you have redirected assembly bindings. Consult the documentation of
the <nunit2> task for more information.

: [Target
"NUnit_TeamCity_generated_670457e5ff2740678b614ed8238a0189" in project
"Greinir.Web.sln.teamcity.patch.tcprojx"] Could not load file or
assembly 'nunit.framework, Version=2.2.0.0, Culture=neutral,
PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)

We are using version 2.4.6 of NUnit, but nevertheless, it seems it's
always trying to load version 2.2.0.0.

I did have NUnit installed (2.4.6) on the build agent, but reverted
(uninstalled 2.4.6) to including the dll's in the project as mentioned
in a couple of threads here, to no avail.

Now I'm kind of dead in the water. We can run the NUnit tests
manually, but that defeats the purpose of the build server - and we
don't get the fancy reports to include in our final report, something
we'd promised our mentor.

So I turn to the benevolent community of TeamCity users, crying "HELP"
- please :)



0

Hi,

Thanks for your reply.

I chose not to have NUnit in GAC and it seems to work.

However, I'm getting weird run results.

Apparently, all the tests are run, and the build completes without problems. But at the end of the test runs, it complains about not bein able to load one of the assisting assemblies and thus fails the whole process.

Here is an excerpt from the build log:

: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] Tests run: 3, Failures: 0, Not run: 0, Time: 12.047 seconds



: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] Failure executing test(s). If you assembly is not built using NUnit version 2.4.6.0, then ensure you have redirected assembly bindings. Consult the documentation of the ]]> task for more information.
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] Could not load file or assembly 'Greinir.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
StackTrace:

Server stack trace:
at System.Reflection.Assembly._GetExportedTypes()
at System.Reflection.Assembly.GetExportedTypes()
at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at :
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Core.TestRunner.Load(TestPackage package)
at JetBrains.TeamCity.NUnitLauncher.NUnitRunner.LoadTest(String testAssembly, String testName, TestRunner runner) in c:\Agent\work\5eba606ec9e31e70\src\NUnitLauncher\src\NUnit_2_4\NUnitRunner.cs:line 48
at JetBrains.TeamCity.NUnitLauncher.NUnitRunnerBase.Run() in c:\Agent\work\5eba606ec9e31e70\src\NUnitLauncher\src\NUnitRunnerBase.cs:line 58
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] 2008-04-23 21:58:55,133 ERROR JetBrains.TeamCity.NUnitLauncher.NUnitRunnerBase - Could not load file or assembly 'Greinir.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] System.IO.FileNotFoundException: Could not load file or assembly 'Greinir.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] File name: 'Greinir.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"]
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] Server stack trace:
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at System.Reflection.Assembly._GetExportedTypes()
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at System.Reflection.Assembly.GetExportedTypes()
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"]
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] Exception rethrown at :
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at NUnit.Core.TestRunner.Load(TestPackage package)
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at JetBrains.TeamCity.NUnitLauncher.NUnitRunner.LoadTest(String testAssembly, String testName, TestRunner runner) in c:\Agent\work\5eba606ec9e31e70\src\NUnitLauncher\src\NUnit_2_4\NUnitRunner.cs:line 48
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"] at JetBrains.TeamCity.NUnitLauncher.NUnitRunnerBase.Run() in c:\Agent\work\5eba606ec9e31e70\src\NUnitLauncher\src\NUnitRunnerBase.cs:line 58
: [Target "NUnit_TeamCity_generated_aae66e4f3a7a4cb390a014d852432e2d" in project "Greinir.Web.sln.teamcity.patch.tcprojx"]


The "Greinir.Core" is an assembly which is a part of the project, and is marked as "Copy local" in the "Greinir.Tests" project.

I'm wondering why it might fail like this, and can't really see any logical explanation.

Currently, the TeamCity i'm using is version 3.1.1.

Thanks in advance.

0

I forgot to mention - if I run the tests manually (with the NUnit GUI) the tests run perfectly fine, and there's no error..

0

Hi,

How can you run the tests if you don't have NUnit in GAC? Did you add nunit.*.dll to VCS? If so, you also need to add "Greinir.Core" to VCS.

http://intellij.net/forums/thread.jspa?messageID=5211523

Edited by: t800t8 on Apr 24, 2008 10:15 PM

0

Yes, I added all needed parts to the VCS.

All the Greinir.* assemblies are referenced and "Copy Local" in the VCS, so that's not a problem.

As I said, the tests run fine when run with the NUnit GUI...

0

Could you please check if Greinir.* assemblies are in the folder near tests dlls. What target is used to build the solution? What runner do you use? Do you have some custom configurations in .sln file? If so, does it includes building Greinir.* assemblies?

Does all of those assemblies created if to start msbuild.exe from console on cleaned sources?

0

We are having a similar problem with one of our projects. When we run our builds on our dev PC's they build correctly, and all the tests run (in Nunit, or in resharper test runner). Once we commit to TeamCity the build starts, finishes compiling, runs all the tests and once all the tests have passed this error appears:

: Target "NUnit_TeamCity_generated_d1d65d465958441f971e0a3cc2d3caf8" in project "MyProj.sln.teamcity.patch.tcprojx" (1m:53s)
: [Target "NUnit_TeamCity_generated_d1d65d465958441f971e0a3cc2d3caf8" in project "MyProj.sln.teamcity.patch.tcprojx"] Failure executing test(s). If you assembly is not built using NUnit version 2.4.6.0, then ensure you have redirected assembly bindings. Consult the documentation of the ]]> task for more information.
: [Target "NUnit_TeamCity_generated_d1d65d465958441f971e0a3cc2d3caf8" in project "MyProj.sln.teamcity.patch.tcprojx"] Could not load file or assembly 'MyProj.Test, Version=1.3.0.32918, Culture=neutral, PublicKeyToken=c826c4967ee16d9f' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

We are using the nunit.framework.dll version 2.4.6, referenced directly from each test project. We are using C#, TeamCity 3.1.1 (build 6828). It seems like the build is fully successful but then it fails after finishing the tests.

0

Actually, for our build, it "magically" started working when only a few weeks were left of the project.

What happened at that time was that I deemed the tests written up to that point bad, and rewrote all the test classes. I still kept getting the same errors tho, so I started to fiddle around with the settings. These are my project settings regarding build and test:

Runner: sln2005
Type of runner: sln2005 (Runner for Microsoft Visual Studio 2005 solution files)
Solution file path: greinir\Greinir.Web\Greinir.Web.sln
Working directory: same as checkout directory
Targets: Rebuild
Configuration: Debug
Solution Platform: default
NUnit Run platform: auto(MSIL)
NUnit runner: NUnit 2.4.6
Run tests from: Greinir.Tests\bin\Debug\Greinir.Tests.dll
Do not run tests from: none specified
NUnit categories include: none specified
NUnit categories exclude: none specified

The main difference being that instead of using the double star in the path ("**") I pointed directly to the resulting dll containing all the tests.

0

Could you please specify the path relative to checkout. If that fails please try specifying it relative to .sln file location. Does that work?

The most relyable way for it is to use $(MSBuildProjectDirectory) property which resolves to the folder containing .sln file.

Thanks.

0

You need to fiddle around with bindingredirects:

http://nant.sourceforge.net/release/0.85-rc2/help/tasks/nunit2.html

you need to put in something like this.

... ]]>

I'll try to lookup get the specific code and post it later.

0

I'm also running into the same problem as well. (I'm using sln2008) I finally figured out the problem. When you use MSBuild wildcard '**', make sure you need to exclude */obj/* directory. NUnit will fail if that directory is not excluded from the path. There's another copy of your test assembly under that path without all the assemblies it references.

Edited by: shinakuma on Jun 7, 2008 4:36 AM

0

This usually boils downs to the same assembly included twice, from obj and bin folders. It is easy to do when using the ** glob pattern to include assemblies. Neither Teamcity nor NUnit prevents this, and NUnit fails miserably with an unfriendly error message.

As usual, you will have to live with this, or implement any prevention tool yourself.

0

Hello,

We a have a related feature request: https://youtrack.jetbrains.com/issue/TW-12837, please comment/vote for it.

0

Please sign in to leave a comment.