I'm building an installer for OS X for an app that requires mono. I need to be able to install Mono if it isn't already installed. Any pointers on how I can accomplish that?

As a sub question...would it be possible to do that without including the Mono installer within my installer (i.e. if necessary download it from the internet).



asked 09 May '13, 12:29

exvance's gravatar image

accept rate: 0%

There are multiple issues with the question.

First one is to detect if Mono is installed. A simple solution is to just check if /Library/Frameworks/Mono.framework exists - for example:

<if> <actionList> <setInstallerVariable> <name>mono_is_installed</name> <value>1</value> </setInstallerVariable> </actionList> <conditionRuleList> <fileExists> <path>/Library/Frameworks/Mono.framework</path> </fileExists> </conditionRuleList> <elseActionList> <setInstallerVariable> <name>mono_is_installed</name> <value>0</value> </setInstallerVariable> </elseActionList> </if>

As for installing it, the easiest approach is to ship the installer (the *.pkg file) in a downloadable component. This way, the installer itself will not have the *.pkg file, but if the component is selected

  <programArguments>-W "${installdir}/MonoFramework.pkg"</programArguments>
  <progressText>Install Mono Framework</progressText>

And a more or less complete example is:

<project> (...) <componentList> (...) <component> <name>monoinstaller</name> <description>Mono Installer</description> <canBeEdited>0</canBeEdited> <downloadable>1</downloadable> <selected>0</selected> <show>0</show> <folderList> <folder> <description>Mono Installer</description> <destination>${installdir}</destination> <name>monoinstaller</name> <platforms>all</platforms> <distributionFileList> <distributionFile> <origin>MonoFramework.pkg</origin> </distributionFile> </distributionFileList> </folder> </folderList> <postInstallationActionList> <runProgram> <program>open</program> <programArguments>-W "${installdir}/MonoFramework.pkg"</programArguments> <progressText>Install Mono Framework</progressText> </runProgram> <deleteFile> <path>${installdir}/MonoFramework.pkg</path> </deleteFile> </postInstallationActionList> </component> </componentList> <readyToInstallActionList> <if> <actionList> <setInstallerVariable> <name>mono_is_installed</name> <value>1</value> </setInstallerVariable> <componentSelection> <deselect></deselect> <select>monoinstaller</select> </componentSelection> </actionList> <conditionRuleList> <fileExists> <path>/Library/Frameworks/Mono.framework</path> </fileExists> <platformTest> <type>osx</type> </platformTest> </conditionRuleList> <elseActionList> <setInstallerVariable> <name>mono_is_installed</name> <value>0</value> </setInstallerVariable> <componentSelection> <deselect>monoinstaller</deselect> <select></select> </componentSelection> </elseActionList> </if> </readyToInstallActionList> (...) </project>

You can find out more about making components downloadable in Downloadable Components section of InstallBuilder user guide.

Another, more complex option is to use HTTP Get action to download the DMG file, then use <runProgram> action to run the hdiutil OS X command to mount and unmount the DMG file and running the *.pkg installer directly from DMG.

However, that option is more error prone - such as download file URLs may change, naming convention inside DMG may change - and we recommend shipping the *.pkg in your installer or using downloadable components and making it optionally downloadaded as part of the installation.


answered 13 May '13, 03:25

wojciechka's gravatar image

wojciechka ♦♦
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 09 May '13, 12:29

Seen: 2,438 times

Last updated: 13 May '13, 03:25