abort on error in post-install actions

Comments

4 comments

  • Avatar
    michiel

    Hi Chris,

    My apologies for the late reply. It's not possible to rollback the installation if an error occurs in a post installation action. But it's possible to use the <exit> action to exit with a different exit code in case an error occurs. For example:

     <runProgram program="some_program">
        ...
       <onErrorActionList>
           <exit exitcode="1"/> 
        </onErrorActionList>
        ...
     </runProgram>

    You can also add other actions like showing the user a warning that the installation did not succeed.

    Regards,

    Michiel

     

    0
    Comment actions Permalink
  • Avatar
    Chris

    Okay, that might just be crazy enough to work... However, we've really got quite a few post-install actions, so decorating each of them in this fashion is impractical. If we instead wrap our many post-install actions in an actionGroup that has an onErrorActionList, will those on-error actions fire when any action in the actionGroup raises an error? Something like this, I'd imagine:

    <actionGroup>
    <runProgram />
    <doSomething />
    <doSomethingElse />
    <onErrorActionList>
    <showWarning title="Install failed" text="Something terrible has happened..." />
    <exit exitcode="1" />
    </onErrorActionList>
    </actionGroup>

    If so, I reckon we're back in business.

    0
    Comment actions Permalink
  • Avatar
    Chris

    As it turns out, this works. Mostly. I am having trouble when the failing action belongs to a construct like this:

    <showProgressDialog>
    <actionList>
    <foreach>
    <variables>folder</variables>
    <values>...
    <actionList>
    <runProgram>
    <program>...
    <workingDirectory>...
    <programArguments>...
    <abortOnError>true</abortOnError>
    <showMessageOnError>false</showMessageOnError>
    </runProgram>
    </actionList>
    </foreach>
    </actionList>
    </showProgressDialog>

    When the actionGroup's actionList contains a showProgressDialog, the runProgram errors are recorded by the installer log - but the actionGroup's onErrorList actions never fire. If I explicitly cancel the progress dialog by clicking on the "X", the actionGroup's onErrorList actions do fire.

    If I instead attach an onErrorActionList to the runProgram, I can cause the installer to abort by using either a throwError or an exit action. However in both those cases, the installer exits without firing any actions in the project's installationAbortedActionList.

    Is something special required to propagate errors from showProgressDialog up to the installer?

    0
    Comment actions Permalink
  • Avatar
    michiel

    Hi Chris,

    This behavior is expected. When showMessageOnError is disabled and abortOnError is enabled, and an error occurs the rest of the actions will be skipped. But although the actions will be skipped, the error will not be propagated so the installation will not be aborted. To propagate the error you need to set showMessageOnError=1.

    Regards,

    Michiel

    0
    Comment actions Permalink

Please sign in to leave a comment.