Bug 34675 - Mono 4.0.4 fails to launch NUnit test runner on TeamCity
Summary: Mono 4.0.4 fails to launch NUnit test runner on TeamCity
Alias: None
Product: Tools
Classification: Mono
Component: other ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-10-08 03:22 UTC by Prashant Cholachagudda
Modified: 2015-12-18 05:02 UTC (History)
6 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Prashant Cholachagudda 2015-10-08 03:22:30 UTC
Mono is unable to run the unit runner our CI server uses due to a corlib issue. Here’s an example of the output:

$ /Library/Frameworks/Mono.framework/Versions/4.0.4/bin/mono /Users/builduser/Documents/TeamCity/buildAgent/plugins/dotnetPlugin/bin/JetBrains.BuildServer.NUnitLauncher.exe
Corlib not in sync with this runtime: expected corlib version 117, found 111.
Loaded from: /Library/Frameworks/Mono.framework/Versions/4.0.4/lib/mono/4.0/mscorlib.dll
Download a newer corlib or a newer runtime at http://www.mono-project.com/download.

However if we run it with the earlier version of mono that is on the system it works just fine:

$ /Library/Frameworks/Mono.framework/Versions/3.12.1/bin/mono /Users/builduser/Documents/TeamCity/buildAgent/plugins/dotnetPlugin/bin/JetBrains.BuildServer.NUnitLauncher.exe
TeamCity is unavailable. Messages will be printed to standard output
<myFlowId />
….. more output from NUnitLauncher.exe

Version information

=== Xamarin Studio ===

Version 5.9.7 (build 12)
Installation UUID: 709b15d7-3403-406d-b153-4e82edf57833
Mono 4.0.4 ((detached/d481017)
GTK+ 2.24.23 (Raleigh theme)

Package version: 400040004

=== Apple Developer Tools ===

Xcode 7.0.1 (8228)
Build 7A1001

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 1d27ac2
Branch: master
Build date: 2015-09-25 18:08:44-0400

=== Xamarin.Android ===

Version: (Starter Edition)
Android SDK: /Users/builduser/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.4 (API level 19)
5.0 (API level 21)
Java SDK: /usr
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

=== Xamarin Android Player ===

Not Installed

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 509070012
Git revision: 2635bd7e508e5bc4c19438e45eefdd9a75232ecb
Build date: 2015-09-25 15:52:15-04
Xamarin addins: 6e0ed86be96e8bd589ba9bc0f50d7121c4dd0d30

=== Operating System ===

Mac OS X 10.10.5
Darwin xamarinmacbuilds 14.5.0 Darwin Kernel Version 14.5.0
Wed Jul 29 02:26:53 PDT 2015
root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 1 Rodrigo Kumpera 2015-10-16 12:21:58 UTC
How exactly is mono being invoked by TeamCity?

It don't see how it could be trying to load files out of a reference folder and not the right place.

It should not be using  /Library/Frameworks/Mono.framework/Versions/4.0.4/lib/mono/4.0 at all.
Comment 2 Rodrigo Kumpera 2015-10-16 13:44:31 UTC
I need to know environment variables passed to mono.

Plus, in order to troubleshoot it, passing the follow two env vars will produce log output that will help me here MONO_LOG_LEVEL=debug and MONO_LOG_MASK=asm
Comment 3 gdunko 2015-10-19 13:43:58 UTC
I ran it from a shell with the same error.  Here is the current environment when running it:

xamarinmacbuilds:foo builduser$ env

After setting the two environment variables you requested here is the output:

xamarinmacbuilds:foo builduser$ /Library/Frameworks/Mono.framework/Versions/4.0.4/bin/mono /Users/builduser/Documents/buildAgent/plugins/dotnetPlugin/bin/JetBrains.BuildServer.NUnitLauncher.exe
Mono: Assembly Loader probing location: '/Library/Frameworks/Mono.framework/Versions/4.0.4/lib/mono/4.0/mscorlib.dll'.
Mono: Image addref mscorlib[0x78e8fde0] -> /Library/Frameworks/Mono.framework/Versions/4.0.4/lib/mono/4.0/mscorlib.dll[0x79242600]: 2
Mono: Assembly Loader loaded assembly from location: '/Library/Frameworks/Mono.framework/Versions/4.0.4/lib/mono/4.0/mscorlib.dll'.
Mono: Assembly mscorlib[0x78e8fde0] added to domain JetBrains.BuildServer.NUnitLauncher.exe, ref_count=1
Mono: Assembly Loader probing location: '/Users/builduser/Documents/buildAgent/plugins/dotnetPlugin/bin/JetBrains.BuildServer.NUnitLauncher.exe'.
Mono: Image addref JetBrains.BuildServer.NUnitLauncher[0x78ea7060] -> /Users/builduser/Documents/buildAgent/plugins/dotnetPlugin/bin/JetBrains.BuildServer.NUnitLauncher.exe[0x799ef400]: 2
Mono: Assembly JetBrains.BuildServer.NUnitLauncher[0x78ea7060] added to domain JetBrains.BuildServer.NUnitLauncher.exe, ref_count=1
Mono: Assembly Loader loaded assembly from location: '/Users/builduser/Documents/buildAgent/plugins/dotnetPlugin/bin/JetBrains.BuildServer.NUnitLauncher.exe'.
Corlib not in sync with this runtime: expected corlib version 117, found 111.
Loaded from: /Library/Frameworks/Mono.framework/Versions/4.0.4/lib/mono/4.0/mscorlib.dll
Download a newer corlib or a newer runtime at http://www.mono-project.com/download.
xamarinmacbuilds:foo builduser$
Comment 4 Zoltan Varga 2015-10-19 14:59:01 UTC
The error means that there is a mismatch between the mono runtime version used and the version of mscorlib.dll. I'd guess there is a newer mono in the PATH somewhere, and the app tries to spawn a new process.
Comment 5 Rodrigo Kumpera 2015-10-19 15:05:06 UTC
Nop, that's not the issue.

The problem is that the runtime is trying to use lib/mono/4.0, which are reference only assemblies.

They are stripped and exists only for the compiler.

We got a repro internally. Working on a fix next.
Comment 6 Rodrigo Kumpera 2015-10-19 15:05:39 UTC
The issue comes from the app.config file that leads the runtime to use a broken runtime configuration.
Comment 7 Alexander Köplinger [MSFT] 2015-10-19 16:30:13 UTC
This is fixed with https://github.com/mono/mono/pull/2148.

As a workaround, you can edit <build agent installdir>/plugins/dotnetPlugin/bin/JetBrains.BuildServer.NUnitLauncher.exe.config 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.
Comment 8 Alexander Köplinger [MSFT] 2015-10-23 11:26:04 UTC
I've added a trello card to get this fix into C6SR1: https://trello.com/c/JAcfXdJR/58-mono-bug-34675-mono-4-0-4-fails-to-launch-nunit-test-runner-on-teamcity
Comment 9 Arpit Jha 2015-12-18 05:02:23 UTC
I have checked this issue and its working fine.

Steps I have followed.
1.Add Team City in XS -> Preference -> Nuget ->Source.
2.Create a Console App.
3.Add a configuration file.
4.Implement following code snippet in Config file.

<?xml version="1.0" encoding="utf-8"?>
<!-- Uncomment one of those to show the crash -->
 <supportedRuntime version="v4.0.20506"/>
<!-- <supportedRuntime version="v4.0.30128"/> -->

5.Run the app.

Observed that its working fine not getting any crash in console.

Hence closing this issue.

Screencast: http://www.screencast.com/t/wxGsIH7A

Environment Info: