Bug 23696 - NUnitTestRunner.cs fails to compile against mono 3.10
Summary: NUnitTestRunner.cs fails to compile against mono 3.10
Status: RESOLVED DOWNSTREAM
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Deployment (show other bugs)
Version: 5.5
Hardware: PC Linux
: --- normal
Target Milestone: master
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-10-09 01:41 UTC by Matthias Mailänder
Modified: 2015-07-27 08:24 UTC (History)
7 users (show)

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


Attachments

Description Matthias Mailänder 2014-10-09 01:41:17 UTC
[  220s] Errors:
[  220s] 
[  220s] /home/abuild/rpmbuild/BUILD/monodevelop-5.5/Main.sln (default targets) ->
[  220s] (Build target) ->
[  220s] /home/abuild/rpmbuild/BUILD/monodevelop-5.5/src/addins/NUnit/NUnitRunner/NUnitRunner.csproj (default targets) ->
[  220s] /usr/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->
[  220s] 
[  220s] 	NUnitTestRunner.cs(105,44): error CS0103: The name `LoggingThreshold' does not exist in the current context
[  220s] 	NUnitTestRunner.cs(105,14): error CS1501: No overload for method `Run' takes `4' arguments
[  220s] 
[  220s] 	 87 Warning(s)
[  220s] 	 2 Error(s)
[  220s] 
[  220s] Time Elapsed 00:00:32.0060250
[  220s] make[1]: *** [sln_build] Error 1
[  220s] make[1]: Leaving directory `/home/abuild/rpmbuild/BUILD/monodevelop-5.5'

Trying to update https://build.opensuse.org/package/show/home:Mailaender:branches:Mono:Factory/monodevelop after bug 17949 has been resolved.
Comment 1 Craig Minihan 2014-11-06 14:24:57 UTC
I get the error:
/home/craig/code/monodevelop/main/Main.sln (default targets) ->
(Build target) ->
/home/craig/code/monodevelop/main/src/addins/NUnit/NUnitRunner/NUnitRunner.csproj (default targets) ->
(BeforeBuild target) ->

	/home/craig/code/monodevelop/main/src/addins/NUnit/NUnitRunner/NUnitRunner.csproj: error : Command 'mono /home/craig/code/monodevelop/main//external/nuget-binary/NuGet.exe restore -SolutionDirectory /home/craig/code/monodevelop/main/' exited with code: 1.

If I remove the BeforeBuild from the csproj I see the error reported here. If I run the failing command directly I see:
$ mono /home/craig/code/monodevelop/main//external/nuget-binary/NuGet.exe restore -SolutionDirectory /home/craig/code/monodevelop/main/
This folder contains no solution files, nor packages.config files.

This seems to be a problem on 3.8 and 3.10 built from tar.
Comment 2 Craig Minihan 2014-11-06 14:50:32 UTC
To resolve the NUnitTestRunner.cs LoggingThreshold problem at line 105 change:
  return tr.Run (listener, filter, false, LoggingThreshold.All);
to:
  return tr.Run (listener, filter);

Which reveals the next problem:
		Project "/home/craig/Downloads/monodevelop-5.5/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj" (default target(s)):
			Target BeforeBuild:
				Tool /usr/local/lib/mono/4.5/mcs.exe execution started with arguments:  /out:BuildVariables.gen.exe BuildVariables.gen.cs
				Executing: mono /home/craig/Downloads/monodevelop-5.5/src/core/MonoDevelop.Core/BuildVariables.gen.exe .
				Deleting file '/home/craig/Downloads/monodevelop-5.5/src/core/MonoDevelop.Core/BuildVariables.gen.exe'
				Executing: "/usr/bin/git" rev-parse HEAD > ../../../build/bin/buildinfo
				fatal: Not a git repository (or any parent up to mount point /home)
				Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
/home/craig/Downloads/monodevelop-5.5/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj: error : Command '"/usr/bin/git" rev-parse HEAD > ../../../build/bin/buildinfo' exited with code: 128.
				Executing: "/usr/bin/git" rev-parse HEAD > ../../../vcrevision
				fatal: Not a git repository (or any parent up to mount point /home)
				Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
/home/craig/Downloads/monodevelop-5.5/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj: error : Command '"/usr/bin/git" rev-parse HEAD > ../../../vcrevision' exited with code: 128.

---------------------------------------------
Executing git directly yields:
"/usr/bin/git" rev-parse HEAD > ../../../build/bin/buildinfo
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Which would be right since this is a monodevelop build from tar (5.5.0.227 from http://download.mono-project.com/sources/monodevelop/) not from a git clone.
Comment 3 Craig Minihan 2014-11-06 15:29:43 UTC
I can build the 5.1 branch from git against 3.10, but not the 5.2 branch. It looks like it solves the editor formatting issues in 5.0.1 which were driving me nuts.

The 5.2 error was:
/home/craig/code/monodevelop/main/Main.sln (default targets) ->
(Build target) ->
/home/craig/code/monodevelop/main/src/addins/AspNet/MonoDevelop.AspNet.csproj (default targets) ->
/usr/local/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->

	Razor/RazorSyntaxMode.cs(38,18): error CS0234: The type or namespace name `Razor' does not exist in the namespace `System.Web.Mvc'. Are you missing an assembly reference?
	Razor/RazorCSharpParser.cs(35,18): error CS0234: The type or namespace name `Razor' does not exist in the namespace `System.Web.Mvc'. Are you missing an assembly reference?

	 2 Warning(s)
	 2 Error(s)
Comment 4 Jo Shields 2014-12-21 09:23:53 UTC
Which version of NUnit are you compiling against? 2.6.3 is needed
Comment 5 Matthias Mailänder 2014-12-21 09:27:04 UTC
The version that is shipped with Mono 3.10: NUnit version 2.4.8
Comment 6 Jo Shields 2014-12-21 09:34:15 UTC
NUnit shipped with Mono has never been suitable for use by external apps, it's for use only internally by the Mono test suite.

5.0.1 worked because it bundles NUnit.Core.dll etc. These are no longer bundled, as they complicate inclusion of MonoDevelop in Linux distributions which care about distributing Free Software only.

You need an NUnit 2.6.3 RPM.
Comment 7 Matthias Mailänder 2014-12-21 11:18:50 UTC
Added NUnit 2.6.4 https://build.opensuse.org/request/show/266053 but it looks like the one supplied by Mono is hiding it as https://build.opensuse.org/package/show/home:Mailaender:branches:Mono:Factory/monodevelop still fails to build with the same error.
Comment 8 Jo Shields 2014-12-21 14:01:34 UTC
xbuild needs a .pc file available to resolve assembly references. Steal the .pc stuff from https://github.com/directhex/xamarin-nunit/tree/centos
Comment 9 Matthias Mailänder 2014-12-21 14:58:17 UTC
Updated https://build.opensuse.org/request/show/266089 but it looks like xbuild still does not resolve them properly.
Comment 10 Jo Shields 2014-12-21 15:14:44 UTC
Remove the build-requires on mono-nunit?

https://github.com/directhex/xamarin-monodevelop/blob/centos/monodevelop.spec#L46
Comment 11 Matthias Mailänder 2014-12-22 05:43:53 UTC
I forgot to install into the GAC. https://build.opensuse.org/request/show/266134 solves it for NUnit. Thanks for sharing your .spec and pkgconfig files which helped a lot.

The new >600 errors for IPackageManager not found etc. sound like I need to do the same for nuget.
Comment 13 Matthias Mailänder 2014-12-22 08:16:07 UTC
How did you fix

MonoDevelop.PackageManagement/MonoDevelopAggregateRepository.cs(45,24): error CS0506: `MonoDevelop.PackageManagement.MonoDevelopAggregateRepository.LogRepository(NuGet.IPackageRepository, System.Exception)': cannot override inherited member `NuGet.AggregateRepository.LogRepository(NuGet.IPackageRepository, System.Exception)' because it is not marked virtual, abstract or override

and the above mentioned

src/core/MonoDevelop.Core/MonoDevelop.Core.csproj: error : Command '"/usr/bin/git" rev-parse HEAD > ../../../build/bin/buildinfo' exited with code: 128.

errors?
Comment 14 Jo Shields 2014-12-22 08:37:53 UTC
> MonoDevelop.PackageManagement/MonoDevelopAggregateRepository.cs(45,24): error

Are you using NuGet direct from upstream? Build from this branch: https://github.com/mono/nuget/tree/2.8.1-for-mono

There's a convenient tarball at http://origin-download.mono-project.com/sources/nuget/ with a couple of patches to build better on Linux.

> src/core/MonoDevelop.Core/MonoDevelop.Core.csproj: error : Command
'"/usr/bin/git" rev-parse HEAD > ../../../build/bin/buildinfo' exited with
code: 128.

Non-fatal. Ignore.
Comment 15 Matthias Mailänder 2014-12-22 09:03:11 UTC
I also tried downgrading to nuget 2.8.1 from CodePlex. Looks like you hacked it incompatible to the original nuget upstream. While I like the idea of unbundling dependencies. This is not how you do that. Especially that https://github.com/directhex/xamarin-monodevelop/blob/centos/monodevelop.spec#L108 is extremely ugly.
Comment 16 Jo Shields 2014-12-22 09:29:00 UTC
Copying required assemblies into the target directory is *absolutely* how one is supposed to deal with anything without a strong ABI contract. Not doing so means updating that library breaks every app on the system immediately, rather than potentially breaking it at next app build-time (i.e. it prevents breaking running apps)
Comment 17 Matthias Mailänder 2014-12-22 10:42:36 UTC
Well with your incompatible MonoDevelop DirectHex NuGet fork you created quite the DLL hell for me. I solved it by packaging it as mono-nuget https://build.opensuse.org/request/show/266166 alongside the real nuget package. I guess that is okay since it also works well with two different NUnits.

Finally updated MonoDevelop to 5.5 in openSUSE https://build.opensuse.org/request/show/266170 and monodevelop-database https://build.opensuse.org/request/show/266169 Could not find monodevelop-debugger-gdb tarballs.

Thanks for your help! Next time I know who to ask when I run into trouble again.
Comment 18 Jo Shields 2014-12-22 10:51:00 UTC
Merged into monodevelop main tarball. See d60a13af675e68705083ec78861ea7ec0d9a9a7b
Comment 19 Craig Minihan 2015-01-15 09:50:38 UTC
Build MonoDevelop 5.7 under Mono 3.12? Yup, still broken as above. I made a script based on the comments by Jo and Matthias above. WFM and might guide someone else who is in the same hole:

# a script to build MonoDevelop 5.7 under Mono 3.12, most likely will work for all Mono 3.x and MonoDevelop 5.2+
# WFM on CentOS 6.6
 
curl http://download.mono-project.com/sources/monodevelop/monodevelop-5.7.0.660.tar.bz2 -O
tar xvfj monodevelop-5.7.0.660.tar.bz2
cd monodevelop-5.7
 
mkdir temp
pushd temp
 
# it seems parts of MonoDevelop 5.2+ need NUnit 2.6.4, which isn't included (?), so download it and put it in the right place in the tree
curl https://launchpadlibrarian.net/153448659/NUnit-2.6.3.zip -O
unzip NUnit-2.6.3.zip
mkdir -p ../packages/NUnit.2.6.3/lib
cp -fR NUnit-2.6.3/bin/framework/* ../packages/NUnit.2.6.3/lib
mkdir -p ../packages/NUnit.Runners.2.6.3/tools/lib
cp -fR NUnit-2.6.3/bin/lib/* ../packages/NUnit.Runners.2.6.3/tools/lib
 
# cecil needs NUnit 2.5.10 - this is also missing from the tar
curl https://launchpadlibrarian.net/68057829/NUnit-2.5.10.11092.zip -O
unzip NUnit-2.5.10.11092.zip
cp -fR NUnit-2.5.10.11092/bin/net-2.0/framework/* ../external/cecil/Test/libs/nunit-2.5.10
 
# the tar doesn't include the nuget binary, so grab it from github and copy it into the right place
git clone https://github.com/mono/nuget-binary.git
cp -fR nuget-binary/* ../external/nuget-binary/
 
popd
 
# we need to extend the pkgconfig search path if we have a local (non-rpm) Mono build
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
 
# a basic install, set the params as you require
./configure
make && make install
Comment 20 obadz 2015-03-21 04:04:31 UTC
Same error trying to build MD 5.8.2.5 with Mono 3.12.1 on NixOS.
Comment 21 obadz 2015-05-07 08:06:18 UTC
Packaging MonoDevelop is getting increasingly difficult with lots of new external dependencies popping up...

https://github.com/obadz/nixpkgs/commit/d27b8e642ed60a00d9a55003d8799ae9303deb20#diff-f19fba5eaacffa5d9684441625edab92
Comment 22 Hin-Tak Leung 2015-07-27 03:38:55 UTC
Trying to rebuild the fedora 23 monodevelop 5.9.4.5 rpm's on fedora 22 with mono 4.0.2.5 (already did mono 4.0.2.5 and a few dependencies) and got 
   "NUnitTestRunner.cs(105,44): error CS0103: The name `LoggingThreshold' does not exist in the current context"
followed comment 2 replaced 
   return tr.Run (listener, filter, false, LoggingThreshold.All);
to:
    return tr.Run (listener, filter);

and got 


Errors:

.../BUILD/monodevelop-5.9.4/Main.sln (default targets) ->
(Build target) ->
.../BUILD/monodevelop-5.9.4/external/nrefactory/ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj (default targets) ->
/usr/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->

	CSharp/AstStructureTests.cs(38,32): error CS0103: The name `Is' does not exist in the current context
	CSharp/Parser/Statements/TryCatchStatementTests.cs(99,32): error CS0103: The name `Is' does not exist in the current context
...
	CSharp/Analysis/DeclarationSpace/LocalDeclarationSpaceVisitorTests.cs(91,11): error CS0117: `NUnit.Framework.Assert' does not contain a definition for `NotNull'
	IndentationTests/BlockTest.cs(351,11): error CS0117: `NUnit.Framework.Assert' does not contain a definition for `Inconclusive'
	IndentationTests/BlockTest.cs(365,11): error CS0117: `NUnit.Framework.Assert' does not contain a definition for `Inconclusive'

	 562 Warning(s)
	 323 Error(s)

FWIW, I tried both nunit-2.6.3 and nunit-2.6.4.

There seems to be a lot of voodoo advices in this thread - can somebody summarise in plain english? According to comment 19, it sounds like one needs multiple versions of nunit's dumped inside the source tree to build?
Comment 23 Jo Shields 2015-07-27 07:02:24 UTC
(In reply to comment #22)
> There seems to be a lot of voodoo advices in this thread - can somebody
> summarise in plain english? According to comment 19, it sounds like one needs
> multiple versions of nunit's dumped inside the source tree to build?

You don't need any version of nunit in the source tree to build.

The .csproj for the NUnit addin defines a basic unversioned Reference Include, with a hintpath - if the hintpath exists, it uses that. Otherwise it tries to resolve the reference from the GAC or from pkg-config. See comment 8.

Your error indicates it is *not* using nunit 2.6.4 - it's likely using the test-suite-only version of nunit that Mono bundles and really shouldn't be installing (but does so, as per comment 6 and comment 10).
Comment 24 Hin-Tak Leung 2015-07-27 08:11:18 UTC
(In reply to comment #23)

Argh, now it make sense - the mono 4.0.2.5 src rpm get built into a whole lot of things, two of which are mono-nunit and mono-nunit-devel , which seems to be nunit 2.4.8 . I guess I need to uninstall those.

Perhaps nunit rpm's itself should have a Conflict/Obsolete mono-nunit, or monodevelop rpm's itself should have a BuildConflict (if there is such thing) mono-nunit? I'll go file a little bug at redhat's bugzilla...
Comment 25 obadz 2015-07-27 08:24:55 UTC
I also think Mono's xbuild should prioritize pkg-config over the TargetFramework assemblies to give the user control over which dlls it wants to use to build.

That's what we did for NixOS:

https://github.com/NixOS/nixpkgs/blob/df08e5adfc4b2b8b1749e2a4abd6d19c359fa7df/pkgs/development/compilers/mono/pkgconfig-before-gac.patch

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

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.

Note You need to log in before you can comment on or make changes to this bug.