If/Else to skip install isn't working

Comments

10 comments

  • Avatar
    BitRock support

    Hi Whitney,

    You need to add an <actionList> inside the <if> action, containing the actions you want to be executed when the condition is true. The <elseActionList> will execute when the condition is false:

    <if>
    <conditionRuleEvaluationLogic>or</conditionRuleEvaluationLogic>
    <conditionRuleList>
    <fileExists>
    <path>${windows_folder_system}\Macromed\Flash\NPSWF64_30_0_0_134.dll</path>
    </fileExists>
    </conditionRuleList>
    <actionList>
    <runProgram>
    <abortOnError>0</abortOnError>
    <program>install_flash_player_30_plugin.exe</program>
    <programArguments>-install</programArguments>
    <workingDirectory>${system_temp_directory}</workingDirectory>
    </runProgram>
    </actionList>
    <elseActionList>

    <!-- the else actions -->

    </elseActionList>
    </if>

     

    Regards,

    Michiel

  • Avatar
    Whitney Clarke

    I understand that.  I want it to SKIP if true.  It did that in the 16 version of InstallBuilder, but not the latest one.  How can I get it to skip installation if true?

  • Avatar
    BitRock support

    Hi,

    You can skip it by adding the rule <fileExists> rule directly to the action and by adding negate="1", so it will only execute when the file does not exists:

     <runProgram>
      <abortOnError>0</abortOnError>
      <program>install_flash_player_30_plugin.exe</program>
      <programArguments>-install</programArguments>
      <workingDirectory>${system_temp_directory}</workingDirectory>
      <ruleList>
        <fileExists negate="1">
          <path>${windows_folder_system}\Macromed\Flash\NPSWF64_30_0_0_134.dll</path>
        </fileExists>
      </ruleList>
    </runProgram>

     

    Would this work for you?

    Regards,

    Michiel

  • Avatar
    Jake

    Hi,

    I am looking to implement something similar to this. I want to force the package install if user pass in a certain parameter, such as --force 1. Normally, if the installer is already installed, it would skip. Below is a snippet I implement, but doesn't seem to work for me.


    <booleanParameter>
    <name>force</name>
    <description></description>
    <explanation></explanation>
    <value>1</value>
    <default>0</default>
    <ask>0</ask>
    </booleanParameter>

    <if>
    <conditionRuleEvaluationLogic>or</conditionRuleEvaluationLogic>
    <actionList>
    <logMessage text="Force parameter used, skip all pre-req check">
    <ruleList>
    <compareVersions>
    <logic>less_or_equal</logic>
    <version1>${oldVersion}</version1>
    <version2>${project.version}</version2>
    </compareVersions>
    </ruleList>
    </logMessage>
    </actionList>
    <conditionRuleList>
    <compareText>
    <logic>equals</logic>
    <text>force</text>
    <value>1</value>
    </compareText>
    </conditionRuleList>
    <elseActionList>
    <throwError>
    <text>The existing installation is newer or equal that the bundled. Aborting testing testing...</text>
    <ruleList>
    <compareVersions>
    <logic>greater_or_equal</logic>
    <version1>${oldVersion}</version1>
    <version2>${project.version}</version2>
    </compareVersions>
    </ruleList>
    </throwError>
    </elseActionList>
    </if>

  • Avatar
    michiel

    Hi Lam,

    In your example you are using a literal string force, instead of ${force}.

    <compareText>
      <logic>equals</logic>
      <text>${force}</text>
      <value>1</value>
    </compareText>

    You also should set the default value to 0:

    <booleanParameter>
      <name>force</name>
      <description></description>
      <explanation></explanation>
      <value>0</value>
      <default>0</default>
      <ask>0</ask>
    </booleanParameter>

    Best regards,

    Michiel

  • Avatar
    Jake
    Thanks for the quick response. When I tried the above suggestion, but my logic go to <elseActionList> logic either I use the --force 1 or not...
    It like it doesn't take in the --force parameter at all.

    <if>
    <conditionRuleEvaluationLogic>or</conditionRuleEvaluationLogic>
    <actionList>
    <logMessage text="Force parameter used, skip all pre-req check"/>
    </actionList>
    <conditionRuleList>
    <compareText>
    <logic>equals</logic>
    <text>${force}</text>
    <value>1</value>
    </compareText>
    </conditionRuleList>
    <elseActionList>
    <logMessage text="Force parameter not used, checking version"/>
    <throwError>
    <text>The existing installation is newer or equal that the bundled. Aborting testing testing...</text>
    <ruleList>
    <compareVersions>
    <logic>greater_or_equal</logic>
    <version1>${oldVersion}</version1>
    <version2>${project.version}</version2>
    </compareVersions>
    </ruleList>
    </throwError>
    </elseActionList>
    </if>

    <booleanParameter name="force" value="0" default="0" ask="0">
    <description></description>
    <explanation></explanation>
    </booleanParameter>
  • Avatar
    BitRock support

    Hi Lam,

    Could you check the value of ${force} before running any other actions? For example using <showInfo text="${force}"/>

    Could you try to use <isTrue value="${force}"/> instead of <compareText> 

    Regards,

    Michiel

     

  • Avatar
    Jake

    Hi,

    When I tried <showInfo text="${force}"/>, I do see that force is "0". I tried using the isTrue, but result still the same.

    <if>
    <conditionRuleEvaluationLogic>or</conditionRuleEvaluationLogic>
    <actionList>
    <logMessage text="Force parameter used, skip all pre-req check"/>
    </actionList>
    <conditionRuleList>
    <isTrue value="${force}"/>
    </conditionRuleList>
    <elseActionList>
    <logMessage text="Force parameter not used, checking version"/>
    <throwError>
    <text>The existing installation is newer or equal that the bundled. Aborting testing testing...</text>
    <ruleList>
    <compareVersions>
    <logic>greater_or_equal</logic>
    <version1>${oldVersion}</version1>
    <version2>${project.version}</version2>
    </compareVersions>
    </ruleList>
    </throwError>
    </elseActionList>
    <ruleList>
    <platformTest type="windows"/>
    </ruleList>
    </if>
  • Avatar
    michiel

    I'm not sure I understand. 

    Could you try the following example:

    <project>
    <shortName>sample</shortName>
    <fullName>Sample Project</fullName>
    <installerFilename>${project.shortname}-installer.${platform_exec_suffix}</installerFilename>
    <osxPlatforms>osx-intel osx-x86_64</osxPlatforms>
    <version>1.0</version>
    <preInstallationActionList>
    <if>
    <conditionRuleEvaluationLogic>or</conditionRuleEvaluationLogic>
    <actionList>
    <showInfo text="Force parameter used, skip all pre-req check">
    </showInfo>
    </actionList>
    <conditionRuleList>
    <compareText>
    <logic>equals</logic>
    <text>${force}</text>
    <value>1</value>
    </compareText>
    </conditionRuleList>
    <elseActionList>
    <throwError>
    <text>The existing installation is newer or equal that the bundled. Aborting testing testing...</text>
    <ruleList>
    </ruleList>
    </throwError>
    </elseActionList>
    </if>
    </preInstallationActionList>
    <componentList>
    <component>
    <name>default</name>
    <description>Default Component</description>
    <canBeEdited>1</canBeEdited>
    <selected>1</selected>
    <show>1</show>
    <folderList>
    <folder>
    <description>Program Files</description>
    <destination>${installdir}</destination>
    <name>programfiles</name>
    <platforms>all</platforms>
    </folder>
    </folderList>
    </component>
    </componentList>
    <disableSplashScreen>1</disableSplashScreen>
    <enableRollback>0</enableRollback>
    <enableTimestamp>1</enableTimestamp>
    <parameterList>
    <booleanParameter>
    <name>force</name>
    <description></description>
    <explanation></explanation>
    <value>1</value>
    <default>0</default>
    <ask>0</ask>
    </booleanParameter>
    </parameterList>
    </project>

    And run the installer in the following way:

    ./installer.exe --force 1

     

     

     

  • Avatar
    Jake

    Okay, so if I put the logic in pre-initialization, it works, but if it's in Initialization, it doesn't work. Is this a expected or bug?

Please sign in to leave a comment.