Trying to get debugging output from Mono NUnit tests - c#

I have a rather large C# library, originally written for .NET and Windows, which we are now porting to Mono and Linux. It is thoroughly unit tested with NUnit. The porting has been fairly simple, but now I need some real debugging features, like error line numbers and breakpoints.
I'm compiling either using VS2010 on Windows 7 or with xbuild on Debian 6.0.2, it really doesn't matter because the binaries are fully compatible. Running tests with Mono 2.10.2 built from tarball, and NUnit 2.5.10 from Debian experimental.
When I run my project in Visual Studio, debugging works fine after I attach to the nunit process. So, does anyone know how I can enable fully-featured Mono debugger support with NUnit tests?
P.S. I've seen this, but I'm compiling with xbuild and running with nunit-console, so I can't manually give arguments to either the compiler or the Mono runtime.
Thanks in advance!
UPDATE: I discovered the pdb2mdb utility, but even when I use this, I still can't get line numbers, which leads me to believe that the code isn't being compiled with --debug. But since I'm using xbuild on a VS .sln file, instead of invoking the compiler directly, how do I use --debug??

Figured it out. Jon Skeet comes to the rescue, once again:
Nunit .net vs mono
After converting to mdb, I needed to run nunit-console.EXE from inside the mono command, like this:
mono --debug /opt/mono-2.10/lib/mono/4.0/nunit-console.exe Test.dll -config=Debug
That took way longer than it should have :P

Related

Linux JetBrains Rider can't use Mono, while it is installed in the system

I am currently using Manjaro Linux 20.2, with official JetBrains Rider from JetBrains Toolbox
I have installed this package package screenshot
When I'm writing in my terminal "mono" it runs.
File location also looks fine.
When I'm opening my Environment tab in Rider. I got this.
Environment Tab
I can create and run/execute/debug any projects with my .NET CORE
But I can't use the framework at all.
A simple application like this New Project Window
And here... the error
In my settings -> build and execution -> I have these parameters
path settings
I don't know what to do and how to fix this error. Tried many times disinstall/reinstall the Mono Package. But it's always the same.
Maybe I should change somehow a Mono path here in Rider Settings ?
But I don't know to where.. there are so many of these files in usr/lib and usr/bin
Please help me, I don't know what to do next and how to fix this..
I just know for sure. That it is possible to run Mono on UNIX.
Something is wrong..
UPD1: I've discovered, that to run Mono on Linux. I should install a different package "monodevelop"
But according to GitHub, this package is not build-able on Linux anymore (only on MacOS)
I've discovered this "dotdevelop" package..
https://github.com/dotdevelop/dotdevelop
But I don't know, it's looks like it doesn't work for me either.
Or maybe I'm just putting a wrong file to my mono path settings in Rider..
UPD2: Maybe there is still hope for me, if I'll use .NET FRAMEWORK from inside a container ?
https://hub.docker.com/_/microsoft-dotnet-framework
I know how to use Docker. It will be possible to use it in my Rider ? I don't get it.
This answer essentially has what you're looking for. There is an issue in recent mono packages for some distributions that causes Rider not to have a proper reference to the mono libraries.
JetBrains Rider not detecting mono or Unity API
I've tried this on Debian 11 and it works as expected. I also use an Ubuntu machine and I didn't have to do this. I'm not entirely sure why, all I know is that some distros need the override set in in order to work. I use KDE Plasma and used their method of setting environment variables. There's a million ways to do that, check Majaro's documentation for what's best for your system.
**Before reading below, be aware that we're talking about legacy software and there's no guaranty that Mono will work in the future since it has been superseded by .NET (core). New development should be done there rather than Mono/.NET Framework unless you really need to. Just be aware it's legacy at this point and ymmv.
As for the other comment that there is no .NET Framework on Linux, that's not completely true. Mono is the .NET Framework implementation for Linux and macOS. It supports a large portion of the .NET Framework that exists in the Windows version, however it has some drawbacks.
For instance, WinForms is only partially supported and extremely buggy. WPF will not work at all.
ASP.NET can be run under Apache with a plugin, however it doesn't support all of the frameworks that you can use on Windows. For modern .NET web development on non Windows platforms, .NET 5+ should be used.
Another weird one is that the Console.Beep() method works unreliably. The Console.Beep(int frequency, int duration) method also doesn't work on macOS at all.
Other than those examples, there's other things that won't work which are mainly things that rely directly on the Windows API though it's possible to run .NET in some capacity under WINE. This isn't recommended though. Anything that uses COM will not work as well. It's also practically impossible to use a printer so that's probably out.
You can review https://www.mono-project.com/docs/about-mono/compatibility/ for a better list of what is and isn't supported.
For console applications, mono works quite well. Just be aware that not everything will work.
Good luck!
You should create a console application by choosing "Console Application" under ".NET Core".
I wonder why Rider guys decided to show the projects under ".NET" to mess things up. Beginners like you won't be easy to know what they are and how to run them on non-Windows machines.

Why does IL2CPP run with no error and no output

My unity version is 5.3.4f, and I hava C# script as a.cs and compiled a.exe and it runs OK. Then I use IL2CPP to translate a.exe into C++ compiled exe a_il2cpp.exe with command:
il2cpp.exe --outputpath=a_il2cpp.exe --cachedirectory="obj_cache" generatedcppdir="generated_cpp" a.exe
But it shows no error and no output, do I miss something? I have C++ compiler installed.
Unity does not support using IL2CPP as a general mechanism for translating C# assemblies to native binaries. In theory this is possible (indeed some of the internal testing tools at Unity do this), but I don't think the command line you mention here will allow it to work.

Compiling applications with mono

I have a few questions about Mono:
1) Is there a way to compile application for Linux without installation of Xamarin Studio?
For example i have my helloworld.cs, i use dmcs to compile it into exe. Is there another compiler or flag to compile app for linux?
2) I need to statically link Mono runtime to run on the computer without Mono installed.
There is mkbundle command but it is a very difficult process to make it work on Windows. And static linking does not work on Windows.
And besides, I need to automate these processes =/
P.S. As I said, I'm working on Windows.
1) It doesn't matter if you compile your code with the Microsoft or Mono compiler, the resulting assembly should work on all platforms (as long as you don't use any platform-specific code of course).
You can take an assembly compiled with the MS compiler and run it on Linux/Mac with Mono, or compile on Mono and run it on Windows/.NET.
2) Problems with mkbundle should probably be filed as a bug on https://bugzilla.xamarin.com

Cross platform build script that can call MSBuild or Xbuild depending on environment?

I have a simple .Net console app which has only framework dependencies. It can compile fine with either MSBuild on windows or Mono/XBuild on linux. It is part of a larger project, which has a python build script. Is there any simple way to determine the most suitable build engine (msbuild/xbuild) and use that?
In other words, I have a 'build.py' and I want that to call xbuild or msbuild as needed.
Far easier would be to write a small shell script for Linux or OSX that ran xbuild but was called msbuild. The arguments are the same I think.

Run .NET exe in linux

Is there any way to run the .NET exe (of a winform app) in Linux without building the code in linux? In fact I don't have the code for some of the utilities I developed earlier and would like to run them in linux.
Related to : Feasibility of C# development with Mono
Mono ! http://mono-project.com/Main_Page
Works great too. There's a growing tool support, C# compiler etc
in a growing community.
You can test it by using the Mono Migration Analyzer or by actually testing it using the Mono command prompt...covered in this article
Wine + .NET

Categories