Can't build NUnit testing project under Mono and Linux

4k views Asked by At

I have a complex solution (developed under Windows, deployed under GNU\Linux) with a number of unit-testing projects, using NUnit 2.9.3.

Here's a reference from project:

<Reference Include="nunit.framework, Version=2.9.3.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\..\..\..\Program Files\NUnit 2.9.3\bin\net-4.0\nunit.framework.dll</HintPath>
</Reference>

I downloaded and built NUnit 2.9.3 from source:

$ xbuild solutions/MonoDevelop/NUnit.Framework.sln /p:Configuration=Release

and installed into GAC:

$ gacutil /i solutions/MonoDevelop/bin/Release/nunit.framework.dll

$ gacutil /l nunit.framework
The following assemblies are installed into the GAC:
nunit.framework, Version=2.9.3.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77
Number of items = 1

and deleted local mono nunit installation:

$ rm /usr/lib/mono/2.0/nunit*
$ rm /usr/lib/mono/4.0/nunit*

but when I try to build my solution:

$ xbuild MySolution.sln | grep error

: error CS0006: Metadata file `/usr/lib/mono/2.0/nunit.framework.dll' could not be found

What do I wrong?

3

There are 3 answers

4
Mikayla Hutchinson On BEST ANSWER

Build tools do not normally resolve assemblies from the GAC (except possibly as a last resort). On .NET they they "assembly folders" registered in the registry. On Mono they use "pkgconfig". You may have removed the nunit assemblies but you did not remove or fix the pkgconfig ("pc") file that tells xbuild and MonoDevelop where to find the dll.

This kind of stuff is why it's a bad idea to alter things installed by packages. You should either uninstall the package properly, or use the appropriate environment variables to override packaged stuff.

In this case, I would suggest you create a pc file for your new nunit assemblies, and put it into the /usr/local/lib/pkgconfig directory (/usr/local is the prefix for installing stuff you build from source), or put it somewhere else and have that somewhere else included in the PKG_CONFIG_PATH environment variable.

See also:

And for some general background on configuring Mono environments, see:

0
Lex Li On

What I will try is to copy the NUnit 2.9.3 to my source file folder such as (solution folder)\lib. Then add this reference locally and make sure the tag matches this local path.

When that is configured, I think xbuild should use this local copy directly instead of reading GAC or other preconfigured paths. If not, I will report a bug to Mono team.

1
dodgy_coder On

The /pkg option of the mono compiler worked fine for me ...

dmcs test.cs /r:System.Configuration.dll /r:System.dll /pkg:nunit

FWIW, I installed nunit using the apt-get package manager (on Ubuntu) ...

sudo apt-get install nunit