Why do I get compilation errors in TC5.0.3 with NUnit 2.5.3?

I have TeamCity 5.0.3 installed and use the sln2008 runner, and the build agent is successfully building the code.  Now I would like to get it to run my NUnit tests, but I get compilation errors:

Window1.xaml.cs(14,7): error CS0246: The type or namespace name ‘NUnit’ could not be found (are you missing a using directive or an assembly reference?)
Window1.xaml.cs(28,10): error CS0246: The type or namespace name ‘Test’ could not be found (are you missing a using directive or an assembly reference?)
Window1.xaml.cs(28,10): error CS0246: The type or namespace name ‘TestAttribute’ could not be found (are you missing a using directive or an assembly reference?)

Here is my current list of things I've checked, and all seems to be in order.

  • I have the HintPath value set properly in my project file (points to the external lib)
  • I can also do a full Release and Debug build from the command line using msbuild
  • I have tried do use the NUnit installer so nunit.framework.dll gets registered into the GAC
  • I have changed the build agent's logon account to be a user on the test system, rather than LOCAL SYSTEM.


Can anyone else recommend some next steps for me to take to debug this issue?  I've posted pictures of my configuration here: http://bit.ly/cy2KDM

Thanks!

15 comments

Hello,

Please try remove and add NUnit.framework reference from GAC

0

Hi Eugene,

I forgot to add that piece of information to my post.  I already tried that by uninstalling NUnit and trying the build runner again.  I also used gacutil and piped to find to make sure there wasn't anything with "nunit" in the GAC.  Is there anything else I should try?  Should I just start over from scratch and see what happens?  That's easy enough to do.

Thanks!

0

Please try do the following:
- create lib folder in your VCS
- put nunit.framework there
- drop all reverences to NUnit in your project
- add those references as path to nunit.framework from lib folder.
- check in/commit changes to your VCS
- try running this build again.

0

Eugene, that's what I've done already.  In my original post, I had stated:

  • I have the HintPath value set properly in my project file (points to the external lib)


But I'll go through the process again and we'll see what happens.

0

Ok, I removed the references, checked in, TC built everything fine.  Then I readded the nunit.framework reference back, pointing to the external libs folder, and it failed again.  Could you please look at the screenshots to see if I made any configuration errors?

0

I rolled back my image and started again with a new solution file, and this time tried just using nunit via the installer, and referenced the dll in the GAC from my solution.  That doesn't work either.

0

Could you please try running your build from msbuild.exe from commandline on the build agent machine logger in using the same user account as was used for build agent service to run.

Do you use any version control system? Please check the file in the build agent's working folder are the same as you expect.

0

I mentioned in my original post that I have already tested it from the command line in debug and release builds.  I have already done this with the local user.  I also tried running the TC build agent service as the local user, as well as LOCAL SYSTEM.  I know that my build agent is running the right code, because the code is only in one place, and when I remove the NUnit dependencies my code compiles fine.

0

Build agent does svn checkout on the agent.
You wrote your project sources are placed in the same directory.
Actually, this is not the recommended case. On the build start according to your changes build agent will remove _all_ files from build working directory
and that fetch all those files from svn back. Have you comitted files to SNV between tries?

Please try using default checkout directory to make TeamCity agent use another folder for building the project.
Have a look to the related documentation at:
http://confluence.jetbrains.net/display/TCD5/Build+Working+Directory
http://confluence.jetbrains.net/display/TCD5/Build+Checkout+Directory

0

Thanks, I'll take a look at it.  I have two branches of my TC installation.  One checks out into c:\builds.  The other just does it in the same folder that I created the project in.  Both fail.  I'll read the docs now, though.  Thanks!

0

Eugene, I was able to get compilation to succeed.  I looked in my error log and noticed that nunit wasn't in the GAC, so maybe I made a mistake and didn't actually add it when I thought I did.

However, I did notice something interesting in the full log.  It said:

Start TeamCity NUnit Test Runner
Assembly file "C:\TeamCity\buildAgent\work\eebe0a91edd637\bin\debug" does not exist.  Assembly is skipped.

I checked that folder, and it does exist.  My exe is also there.  Can you explain why the NUnit runner seems to have not really tested my assembly?

In addition, I cannot use NUnit in this way (with it registered in the GAC).  I need to have NUnit working where it uses the nunit.framework.dll from my external libs folder, which comes from SVN.  I've read that people have been able to use TeamCity in this manner, but I've been unsuccessful so far.  How does TC resolve the dependencies?  From previous replies, it seems that all I need to do is make sure that the HintPath is set correctly, and TC will just use whatever is specified that way in the sln.

Thank you for your help!

0

Glad to read good news!

TeamCity does nothing to resolve those reverences! All it does is starts msbuild.exe for your project.
If you create a project that is makeble (using VS or msbuild.exe) on every machine after checking out from SVN to should work under TeamCity build agent.

You may attach your sameple project for me to check.

Note, there should be no full paths inside <hintpath>. All paths should be relative to .csproj file.

Thanks!

0

interesting... so then, back to my original question   I have a server image where TC cannot build my solution, yet I can do it from the command line with only msbuild just fine.

I'm switching back to that configuration now, and I'll start testing again.  I will submit confirmation of my results shortly.  Thank you very much for the timely responses, it's making this process of getting TC running much easier for me.  

0

Eugene, I think I have an idea of what's going on with my current setup.  I just changed it to use the default checkout folder, which puts it into c:\teamcity\buildagent\(hash)\bin\debug.  I wasn't smart enough before to look at the full log, and today I did that, and now see what could be going on.  The log proves that the HintPath is being used, but the problem now is that it is relative to the checkout folder, and TC doesn't know anything about my external libs folder.

In this case, is the best thing to do to specify a checkout / build folder, so that I can put the external libs folder in a spot that makes it work?  Can I set up TC to automatically svn update that libs folder before a build?

0

Ah, I had assumed that the runner somehow looked at each assembly in the output folder and determined whether or not it was build against the nunit framework.  I specified my exe in the build agent configuration, and it's working!!!

Now, on to NCover 1.5.8.  Please be prepared for a new thread.  

0

Please sign in to leave a comment.