Skip to content

postinst runs after prerm when updating #74

Description

@micheljung

I haven't been able to create an minimal working example yet, but I'm close to it.

It seems to boil down to this:

msi {
  postinst = '''
set shell = CreateObject("WScript.Shell")
shell.LogEvent 4, "postinst executed"
'''
  prerm = '''
set shell = CreateObject("WScript.Shell")
shell.LogEvent 4, "prerm executed"
'''
}

The InstallExecuteSequence from the wxs file:

    <InstallExecuteSequence>
      <Custom Action="Postinst_Script0" Before="InstallFinalize">NOT Installed OR REINSTALL OR UPGRADINGPRODUCTCODE</Custom>
      <Custom Action="SetPropertiesPostinst_Script0" Before="Postinst_Script0"/>
      <Custom Action="Prerm_Script0" After="InstallInitialize">REMOVE</Custom>
      <Custom Action="SetPropertiesPrerm_Script0" Before="Prerm_Script0"/>
    </InstallExecuteSequence>

When you install, you get:

postinst executed

When you remove an installed version, you get:

prerm executed

When you install a new version over an existing one, you get:

prerm executed
postinst executed
postinst executed

Would you agree that this is a bug?

Activity

  1. changed the title [-]postinst runs after prerm[/-] [+]postinst runs after prerm when updating[/+] on Jul 30, 2019
  2. Horcrux7 commented on Jul 30, 2019

    @Horcrux7
    Member

    If you install a new version/update of your installer then msi

    • remove/uninstall the old installation with the old installer first.
    • run the new installer to install the new version

    That I expect that "prerm" is called before "postinst" of the new installer. That the "postinst" is call 2 times seems me sub optimal. The execution condition seems not perfect. Do you have a suggestion?

    A workaround is to use a wxs template. There you can set all execution conditions and the point of actions like you want.

  3. Horcrux7 commented on Aug 7, 2019

    @Horcrux7
    Member

    Any suggestions?

    After looking at https://stackoverflow.com/questions/320921/how-to-add-a-wix-custom-action-that-happens-only-on-uninstall-via-msi/731700#731700 the condition for the Postinst_Script looks ok for me.

    The script should be executed on Install, Repair and Upgrade. This should be valid with: NOT Installed OR REINSTALL OR UPGRADINGPRODUCTCODE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions