I have two installers which I need to install under same installdir. The first one need to verify that the installdir not exist. The second one need to install in the same installdir path which created the first one. I'm using for both installers same include XML file which define the installdir in directory parameter. How can I conditionally create a rule which control this. Let say I would like to check the project.fullname , and according to that to set the directory parameter.

Below is the code which I'm using inside the include XML file:

<directoryParameter> <name>installdir</name> <description>Installer.Parameter.installdir.description</description> <explanation>Installer.Parameter.installdir.explanation</explanation> <value>${platform_install_prefix}/${installsubdir}/${product.vendor}/${product_shortname}</value> <default>${platform_install_prefix}/${installsubdir}/${product.vendor}/${product_shortname}</default> <allowEmptyValue>0</allowEmptyValue> <cliOptionName>prefix</cliOptionName> <mustBeWritable>1</mustBeWritable> <mustExist>0</mustExist> <width>40</width> <validationActionList> <throwError> <customErrorMessage>Installation directory must end with ${product_shortname}</customErrorMessage> <ruleEvaluationLogic>or</ruleEvaluationLogic> <text>Wrong installation directory</text> <ruleList> <regExMatch> <logic>does_not_match</logic> <pattern>.*${product_shortname}$</pattern> <text>${installdir}</text> </regExMatch> </ruleList> </throwError> <throwError> <customErrorMessage>The specified installation directory ${installdir} is not empty</customErrorMessage> <text>Unknown Error</text> <ruleList> <fileExists> <path>${installdir}/eui</path> </fileExists> </ruleList> </throwError> </validationActionList> </directoryParameter>

Thank You, Ronen

This question is marked "community wiki".

asked 12 Sep '12, 05:00

Ronen's gravatar image

accept rate: 0%

Could you provide more details on what you want InstallBuilder to perform? Are you referring to being able to set a different default value for directory parameter based on project properties?

You can do this by using a different variable for the default value - for example you can set default and change it based on platform and/or ${project.fullName}:

<initializationActionList> <!-- default installdir value --> <setInstallerVariable> <name>default_installdir</name> <value>${platform_install_prefix}/${installsubdir}/${product.vendor}/${product_shortname}</value> </setInstallerVariable> <!-- different value for OSX platforms --> <setInstallerVariable> <name>default_installdir</name> <value>/Applications/${installsubdir}/${product.vendor} ${product_shortname}</value> <ruleList> <platformTest> <type>osx</type> </platformTest> </ruleList> </setInstallerVariable> </initializationActionList>

You then need to specify this variable as <default> for the parameter - for example:

<directoryParameter> <name>installdir</name> <description>Installer.Parameter.installdir.description</description> <explanation>Installer.Parameter.installdir.explanation</explanation> <value></value> <default>${default_installdir}</default> ... </directoryParameter>

Regarding the rules, it is safer to use regular expression to extract last element of the directory and then compare it - to avoid issues with characters such as "." being treated as any character by regular expression. Below is a full example:

<validationActionList> <if> <actionList> <setInstallerVariableFromRegEx> <name>installdir_tail</name> <pattern>^.*[/\\](.+?)$</pattern> <substitution>\1</substitution> <text>${installdir}</text> </setInstallerVariableFromRegEx> <throwError> <text>'${installdir}' should end with '${project.fullName}'</text> <ruleList> <compareText> <logic>does_not_equal</logic> <nocase>1</nocase> <text>${installdir_tail}</text> <value>${project.fullName}</value> </compareText> </ruleList> </throwError> </actionList> <conditionRuleList> <regExMatch> <logic>matches</logic> <pattern>^.*[/\\](.+?)$</pattern> <text>${installdir}</text> </regExMatch> </conditionRuleList> <elseActionList> <throwError> <text>Invalid installation directory</text> </throwError> </elseActionList> </if> </validationActionList>


answered 12 Sep '12, 10:18

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: 12 Sep '12, 05:00

Seen: 1,185 times

Last updated: 12 Sep '12, 10:18