从命令行运行 Xamarin 项目 [英] Run Xamarin project from command line
问题描述
我在 OSX 上有一个 C# 项目,我通过 Xamarin 构建和执行.如何从命令行运行这个项目?我需要向 mono
传递哪些参数?
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
?
推荐答案
虽然我的 Xamarin 项目最初是构建 OSX 应用程序而不是独立的 Mono 可执行文件,但可以先构建一个单独的可执行文件并使用 mono 运行它.
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.
对我来说,这涉及使用我的 Xamarin 项目使用的每个源文件和每个 DLL 运行 mcs
(单声道编译器).我的大部分源文件都在一个目录中,Xamarin 会在 ./bin/Debug/XXXXXXXXXXX.app/Contents/MonoBundle/
下为你收集你所有的 DLL.我获取了所有这些 DLL,将它们移动到一个新目录 lib
.然后我可以像这样编译我的项目:
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
这将输出一个带有第一个源文件名称的单声道可执行文件.它可以通过将文件复制到 lib
目录并在那里运行来运行:
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
这篇关于从命令行运行 Xamarin 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!