Search code examples
c#unit-testingmononunitxbuild

Can't build NUnit testing project under Mono and Linux


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?


Solution

  • 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: