error CS0246: The type or namespace name 'NUnit' could not be found

Hi. I am having a problem with building my solution (.sln) which contain project with unit tests. I have –
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets warning MSB3245: Could not resolve this reference. Could not locate the assembly "nunit.framework, Version=2.4.6.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. UnitTest.cs(4, 7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?) - compile errors when I force build-agent to build the project.

I played with such build runners as: MsBuild, Sln2005 but neither of them worked. But when I build my project from VS2005 everything works fine there are no the compile errors. I checked if the nunit.framework was in GAC but surprisingly I did not find it there. Seemingly VS2005 gets it from "c:\Program Files\NUnit 2.4.6\.." but there is no any absolute path in the .csproj file. So I do not understand how VS2005 resolve the reference on the assembly and why it finds it but build runners on build agent does not. Any ideas?

4 comments
Comment actions Permalink

NUnit.Framework dll of the same version that was used to compile tests classes are looked in
- near test assembly
- in GAC

Please check build agent windows service user account. Does that user have enough rights?

Thanks!

0
Comment actions Permalink

How can I check if the user I loged on has enough rights?

0
Comment actions Permalink

By default Build agent is installed under SYSTEM account. To change/check that please open 'Services MMC console', find there TeamCity BuildAgent service. Thanks!

The easiest way to fix NUnit problem is to put NUnit.Framework.dll near tests assemblies.

The other check could be to create new build configuration with commandline runner with command name cmd and arguments /c whoami

Thanks!

0
Comment actions Permalink

I had the same problem, couldn't figure out what was wrong. The agent login was even set as a local admin.

In the end Eugene's suggestion of putting NUnit in the GAC worked, thanks!

0

Please sign in to leave a comment.