I have a C# project on OSX that I built and execute through Xamarin. How can I run this project from the command line? What parameters do I need to pass to mono
?

- 6,573
- 6
- 23
- 48
-
How come you are not using `MSBuild`? – lolelo Jun 21 '19 at 12:47
2 Answers
Basic usage
The normal way to run an application you have compiled with Mono would be to invoke it through the Mono runtime, like this:
mono myprogram.exe
Ref: The highly outdated doc page @ http://www.mono-project.com/archived/guiderunning_mono_applications/
So, in the most basic form, you only need to pass your CIL-based .exe
to the mono
runtime/executable. For advanced needs, consult the man
page for mono for additional options:
man mono
NAME
mono - Mono's ECMA-CLI native code generator (Just-in-Time and Ahead-of-
Time)
SYNOPSIS
mono [options] file [arguments...]
mono-sgen [options] file [arguments...]
~~~~~~

- 1
- 1

- 73,120
- 10
- 106
- 165
-
Unfortunately when I just run `mono myprogram.exe` I get the following error: `No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting` – user12341234 Mar 10 '16 at 02:50
-
What type of project are you building/running? If you are trying to run a Xamarin.Mac project from the cmd line, you would need to `open MyMonoMac.app`, if this is an iOS project, you can not 'run' it from cmd-line, you would either need to run it from within the iOS Simulator or install it on a iOS device... – SushiHangover Mar 10 '16 at 06:33
-
It is a Mac project, and in fact, it does run when called from `open`, however I'm hoping there's a way to run the project by calling `mono` directly. The end goal is to enable profiling. – user12341234 Mar 10 '16 at 16:25
While my Xamarin project was originally building an OSX app instead of a standalone mono executable, it is possible first to build a seperate executable and run that with mono.
For me this involved running mcs
(the mono compiler) with every source file and every DLL used by my Xamarin project. Most of my source files were in a single directory, and Xamarin kindly gathers all your DLLs in a directory for you under ./bin/Debug/XXXXXXXXXXX.app/Contents/MonoBundle/
. I took all these DLLs, moved them to a new directory lib
. Then I could compile my project like this:
mcs *.cs -r:lib/MonoMac.dll -r:lib/MoreLinq.dll -r:lib/OpenTK.dll
This will output a mono executable with the name of the first source file. It can be run by copying the file into the lib
directory and running it there:
cp Program.exe lib
cd lib
mono Program.exe

- 6,573
- 6
- 23
- 48