Home / Alt manpages / macpack(1)

  • macpack(1)
  • User command
  • linux

Package a Mono GUI Assembly as a Mac OS X Application with macpack

You will turn an existing Mono managed assembly into a Mac OS X application bundle, choose the runtime mode it needs, and add any resources it depends on. The result is a directory that can be copied to a Mac for testing or distribution. This is packaging work, not compilation: you need the assembly before you start.

Allow about ten minutes for a small assembly. The installed command comes from Ubuntu's mono-devel package, version 6.8.0.105+dfsg-3.6ubuntu2 on this system. The tool is old and targets Apple's Mac OS X bundle model, so treat the output as a legacy deployment artefact rather than proof that a modern macOS release will run the program.

Work in a disposable directory first. Creating a bundle changes files beneath the output directory, but it does not install anything system-wide and does not require root.

1. Check the input and the tool

Confirm that the assembly you intend to package exists and identify the installed command:

$ command -v macpack
/usr/bin/macpack
$ dpkg-query -W -f='${Package} ${Version}\n' mono-devel
mono-devel 6.8.0.105+dfsg-3.6ubuntu2
$ test -f Example.exe && echo 'assembly found'
assembly found

macpack expects an assembly argument. Keep the input in a separate source directory and place generated bundles in a clean output directory. That makes it obvious which files came from the packager and makes a failed attempt easy to remove.

2. Choose the runtime mode

The mode tells the generated application how the Mono class libraries should set up the environment. Choose the one that matches how the program starts:

  • winforms is for a Windows Forms application running through the Quartz integration;
  • x11 is for an application that needs an X11 server;
  • console is for a non-graphical managed program;
  • cocoa is for a Cocoa# application.

Do not choose console merely because packaging is being done from a terminal. The value describes the application, not the shell you happen to be using. An X11 application still needs a working X server on the Mac, while the graphical modes have different runtime expectations.

3. Build a first bundle in a clean directory

Use -m for the mode, -n for the name shown in Finder, and -o for the destination directory. The assembly can be supplied directly, or with the equivalent -a option:

$ mkdir -p macpack-work/out
$ macpack \
    -m winforms \
    -n ExampleApp \
    -o macpack-work/out \
    macpack-work/Example.exe

Replace winforms, ExampleApp and the assembly path with values for your program. The command does not publish a single executable. It prepares an application bundle under the output directory, with the managed assembly and the launcher structure required by the selected mode.

Checkpoint: inspect the generated directory before copying it anywhere:

$ find macpack-work/out -maxdepth 3 -print
macpack-work/out
macpack-work/out/ExampleApp.app
macpack-work/out/ExampleApp.app/Contents
macpack-work/out/ExampleApp.app/Contents/Resources

The exact contents and depth depend on the Mono version and selected mode. The important check is that an application directory named after -n was created beneath the output directory.

4. Add resources deliberately

Use -r for a resource and repeat it for several files. The manpage also accepts a comma-separated list:

$ macpack \
    -m cocoa \
    -n ExampleApp \
    -o macpack-work/out \
    -r macpack-work/assets/logo.png \
    -r macpack-work/assets/defaults.json \
    macpack-work/Example.exe

Resources are copied into the bundle's resources directory. Check that each source exists before packaging; a typo can produce an incomplete bundle that only fails when the application looks for the missing file. Keep resource paths free of secrets and user-specific absolute paths, because the generated bundle is intended to travel to another machine.

5. Verify and recover safely

Compare the bundle with the files you meant to include:

$ find macpack-work/out/ExampleApp.app -type f -print | sort
$ test -d macpack-work/out/ExampleApp.app/Contents/Resources && echo 'bundle structure present'
bundle structure present

Run the application on a compatible Mac installation rather than assuming that successful packaging means successful execution. For an X11 bundle, check the X11 dependency separately. For a GUI bundle, test the actual managed assembly and every resource path.

If the output is wrong, remove only the disposable output directory and run again with a corrected mode or resource list:

$ rm -rf -- macpack-work/out
$ mkdir -p macpack-work/out

This removal is irreversible, so confirm the path before pressing Enter. Never substitute a broad variable or a system directory for macpack-work/out. The source assembly and resource directory remain untouched by this recovery step.

Done means

  • the input assembly exists and was not modified;
  • the selected mode matches the program's GUI or console model;
  • the named .app bundle exists beneath the intended output directory;
  • required resources appear inside the bundle;
  • the bundle has been tested on the target Mac environment before distribution.