Installation in exist directory

Comments

1 comment

  • Avatar
    wojciechka

    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>

Please sign in to leave a comment.