Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity NUnitLauncher running on Linux (mono) gives "Corlib not in sync with this runtime" error

Running a TeamCity build agent to run NUnit tests on Ubuntu 14.04 LTC with the latest build of mono appears to have some dependency issues that I cant for the life of me solve. I have followed the following installation steps

  • Mono Installation Steps for 4.0.1
  • Team City Build Agent

When the TC Build Agent starts the NUnit step, it simply fails, and looking at the logs shows it executes

/usr/bin/mono-sgen /home/ubuntu/buildAgent/plugins/dotnetPlugin/bin/JetBrains.BuildServer.NUnitLauncher.exe

which promptly returns with

Corlib not in sync with this runtime: expected corlib version 117, found 111.
Loaded from: /usr/lib/mono/4.0/mscorlib.dll
Download a newer corlib or a newer runtime at http://www.mono-project.com/download.

Is there any possible way to get this to work? I have tried removing all the pieces and re-installing again and even installing a older version of mono build but to no avail.

The TC connection appears to work and I can manually invoke and call mono on its own and even nunit-console however this .exe build provided by TC seems to have be stumped as linux non-expert.

Please save me from dependency hell!!

Edit: I ended up just solving my problem by installing nunit-console and enabling the XML Report processing build feature rather than play around with the corelib files and break something else.

like image 923
Rob Avatar asked May 01 '15 14:05

Rob


2 Answers

This is a Mono bug, see https://bugzilla.xamarin.com/show_bug.cgi?id=34675.

The problem is that Mono moved to providing the 4.0 assemblies, including mscorlib.dll, only in form of reference assemblies. They contain only metadata and are intended for the compiler. Normally applications just use the newest version automatically.

The loader code in Mono however wasn't updated to bind forward an explicit runtime version of v4.0.20506 or v4.0.30128 which TeamCity is using in their .exe.config files to the latest version. The runtime instead tries to load mscorlib.dll from the 4.0 directory and bails as the version is too old (it's from the time the reference assemblies were generated).

As a workaround, you can edit <build agent installdir>/plugins/dotnetPlugin/bin/JetBrains.BuildServer.NUnitLauncher.exe.config (and other .exe.config files) and remove the following lines:

<supportedRuntime version="v4.0.20506"/>
<supportedRuntime version="v4.0.30128"/>

This might stop working once TeamCity decides to update the plugin though.

like image 145
Alexander Köplinger Avatar answered Sep 22 '22 18:09

Alexander Köplinger


Replacing the mscorlib version is only asking for trouble - i.e. TypeLoadException's and friends are waiting around the corner to get you.

What I did was replace the Teamcity build step with a manual invocation of the TC NunitLauncher, but forcing it to use Mono 4.5:

mono --runtime=4.5 /Applications/buildAgent/plugins/dotnetPlugin/bin/JetBrains.BuildServer.NUnitLauncher.exe v4.0 MSIL NUnit-2.6.3 $(find **/bin/Release/*Tests.dll | paste -sd ";" -)

The invocation uses some shell trickery to find all assemblies I'm interested in using a wildcard, but other than that should be straightforward to understand.

It would be nice if Mono fixed their broken 4.0 runtime. Anyone already reported it on https://bugzilla.xamarin.com/ ?

like image 44
Johannes Rudolph Avatar answered Sep 23 '22 18:09

Johannes Rudolph