假设 Mono 安装在所有目标机器上,那么您可以(手动)放置一个 .app 包文件夹,当用户双击它时,它将运行您的 .exe 文件。您需要在 .app 包中放入一些特定的东西,其中之一是一个命令 shell 文件,它将启动您的 .exe 并在 .app 运行时执行。
顺便说一句,Visual Studio Mac 和 Xamarin Studio 和 MonoDevelop 基本上都是同一个东西 MonoDevelop 的不同转折。VS mac 和 XS 有额外的,但基本的底层 IDE 是 MD。无论您使用这些产品中的哪一个来编译您的代码,都不太可能产生与下一个不同的任何东西。
基本 .app 文件夹的结构:
MyApp.app
+-- Contents
--- Info.plist
+-- MacOS
--- MyApp
--- MyApp.exe
+-- Resources
--- MyApp.icns
内容如下:
Info.plist 是一个 Mac OS 特定的 XML 文件,其中包含对您的 .app 包的描述。它看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>MyApp</string>
<key>CFBundleIconFile</key>
<string>MyApp.icns</string>
<key>CFBundleIdentifier</key>
<string>com.myapp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>My App Name</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<key>CFBundleSignature</key>
<string>xmmd</string>
<key>CFBundleVersion</key>
<string>1.2.3</string>
<key>NSAppleScriptEnabled</key>
<string>NO</string>
</dict>
</plist>
MyApp.icns 文件是您要用作应用程序包图标的图标文件。
MyApp.exe 文件是您编译的 .NET exe。
MyApp 文件是用户执行 .app 包时执行的可执行命令文件。这在 CFBundleExecutable 下的 plist 文件中被引用,并且必须是可执行的(+x 权限,)。这可能是这样的:
#!/bin/sh
DIR=$(cd "$(dirname "$0")"; pwd)
MONO_FRAMEWORK_PATH=/Library/Frameworks/Mono.framework/Versions/Current
export DYLD_FALLBACK_LIBRARY_PATH="$DIR:$MONO_FRAMEWORK_PATH/lib:/lib:/usr/lib"
export PATH="$MONO_FRAMEWORK_PATH/bin:$PATH"
exec mono "$DIR/MyApp.exe"
希望这可以帮助。干杯,马丁。