How to handle Mono as a dependency on OS X


1 comment

  • Avatar

    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.

Please sign in to leave a comment.