0

Im very new in Mac development environment. I installed Visual Studio for Mac, and created a new solution .NET/Gtk 2.0 project to build a GUI file rename tool. I created the tool. However when I build it in debug and release, it generates .exe file which I can only run with the shell.

However, I need to build this program in app bundle so that I can send it over to other users and they can run it by clicking on it. Is there any way to accomplish this?(I have spent a few hours on this but couldn't see a clear document that explain to me. If nothing works then I need to rewrite it in Java).

Thank you so much in advance!

ozimax06
  • 386
  • 3
  • 15
  • I also get an exe when I build for linux and on my ubuntu box with mono installed I can just double click on the executable to run it. If that isn't working perhaps you can create a shell script or native application that runs the exe? – Kelson Ball Dec 09 '16 at 00:43
  • Yes double clicking is not woking, I run it from shell and I don't think that the users will be happy with shell or having to download mono framework to run it. So I guess, I will build it with Java, since I have never built a native Mac App before. Thanks though! – ozimax06 Dec 09 '16 at 00:57

1 Answers1

1

Assuming Mono is installed on all of your target machines then you can put together (manually) a .app package folder that will run your .exe file when a user double-clicks on it. There's a certain set of things you'll need to put in the .app package, one of which is a command shell file that will kick-off your .exe and will be executed when the .app is run.

B.t.w. Visual Studio Mac and Xamarin Studio and MonoDevelop are all basically different twists on the same thing, MonoDevelop. VS mac and XS have extras but the basic underlying IDE is MD. Whichever of these products you use to compile your code is unlikely to churn out anything different to the next.

The structure of the basic .app folder:

MyApp.app
  +-- Contents
      --- Info.plist
      +-- MacOS
          --- MyApp
          --- MyApp.exe
      +-- Resources
          --- MyApp.icns

The contents are as follows:

Info.plist is a Mac OS specific XML file that contains a description of your .app package. It will look something like this:

<?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>

The MyApp.icns file is an icon file you want to use as the icon for your app package.

The MyApp.exe file is your compiled .NET exe.

The MyApp file is an executable command file that is executed when the .app package is executed by the user. This is referenced in the plist file under CFBundleExecutable and has to be executable (+x permissions, ). This is what it might look like:

#!/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"

Hope this helps. Cheers, Martin.

muszeo
  • 2,312
  • 9
  • 13