Run Xamarin project from command line

好久不见. 提交于 2020-01-25 04:23:05

问题


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?


回答1:


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...]
~~~~~~



回答2:


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


来源:https://stackoverflow.com/questions/35906365/run-xamarin-project-from-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!