MacPack (MSBuild Task)

From The Oxygene Language Wiki

Jump to:navigation, search

This is a Platform topic
Feel free to add your notes to this topic below.



Delphi Prism provides a "MacPack" task for MSBuild that automatically packages executables created with Mono as .app packages so they can be run on Mac OS X. The MacPack task is part of RemObjects.Oxygene.Cocoa.targets and performs a varierty of actions for different Mac OS X project types.

In most cases, developers will not need to directly interact with the MacPack task, and it will "just work", when starting out with one of the provided Mac OS X templates in the Mono folder (Cocoa#, Monobjc or WinForms), but this document will illustrate how MacPack works, so users can use and control it manually, if needed.

Using MacPack

the MacPack task will automatically applied to your project and an .app will be generated, as soon as RemObjects.Oxygene.Cocoa.targets is imported into your project using an <Import> tag, as shown below:

<Import Project="$(MSBuildExtensionsPath)\RemObjects Software\Oxygene\RemObjects.Oxygene.Cocoa.targets" />

Properties of the MacPack Task

Property
Description
ApplicationName Specifies the name of the application to be generated; controlling both the actual file name of the generated .app, but also the internal application name as it will show in the Menu bar. If not set explicitly, ApplicationName will use the AssemblyName configured for the .NET assembly you are building.
ApplicationIdentifier Specifies the applicention identifier that uniquely identifier your executable on the Mac OS X system. This identifiier should use the common reverse domain notation, such as "com.mycompany.myapplication". If not set explicitly, this will be set to "com.AssemblyName".
OutputPath The target directoy where .app will be generated. By default, the same as then output directory for the original .NET assembly, meaning that your .app will be generated next to the un-packaged .exe file.
EntryAssembly The name of the .exe file to use as entry point. Usually, there is nio need to set this explicitly, and it will default to use the AssemblyName setting of the project
Mode The type of application to package for. Value values include:
  • Cocoa (for Cocoa#)
  • Monobjc (not officially supported in 3.0.15, yet)
  • WinForms (for Windows Forms based applications)
  • X11 (for X11 based applications not using WinForms or Cocoa; not officially supported by Delphi Prism)
  • Console (for command line applications without user interface; not officially supported by Delphi Prism)
IconFile Specifies the .ICNS file to be used as application icon. The specified ICNS file will automatically be copied as resource into the application package.
InfoPListFile Specifies a custom Info.plist fiel to be used to describe the application. If not specified, macPack will generate a default Info.plist file based on information provided by the ApplicationName, ApplicationIdentifier and IconFile properties. Note: if a custom plist file is specified, the %APPNAME%, %IDENTIFIER% and %ICONFILE% place holders can be used for the above three properties.
Resources Specifies a list of additional resource files to be copied into the application package's Resources folder. These can be images, audio or video files, or other files that your application needs to reference at run time.

You can easily specify files to be included as resources by setting their build action to MacResource within the IDE.

Actions performed by the MacPack Task

When enabled by importing RemObjects.Oxygene.Cocoa.targets, the MacPack task will be invoked after compilation of the .NET executable has been completed, and perform the following tasks:

  1. Rename any existing .app folder to .app~ as backup (deleting any existing .app~).
  2. Create a new .app folder and the subfolders required for an application bundle. these include
    • ApplicationName.app
    • ApplicationName.app/Contents
    • ApplicationName.app/Contents/MacOS
    • ApplicationName.app/Contents/Resources
  3. Copy any specified MacResources to the Resources folder
  4. Copy any .NIB bundles to the Resources folder (omitting designable.pas and .svn items)
  5. Copy any specified icon file to the Resources folder
  6. Copy the . NET executable and all refrenced assemblies with CopyLocal=true to the Resources folder
  7. Generate a proper loader shell script in the MacOS folder, depending on the specified Mode.
  8. Generate or copy the apporriate Info.plist in the Contents root folder

See Also


Oxygene-48.png

Area: Oxygene Platforms

Platform GlossaryKeywordsTypesFAQHow To

Navigation
Areas
More
Toolbox