Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postinst runs after prerm when updating #74

Open
micheljung opened this issue Jul 30, 2019 · 2 comments
Open

postinst runs after prerm when updating #74

micheljung opened this issue Jul 30, 2019 · 2 comments

Comments

@micheljung
Copy link
Contributor

micheljung commented Jul 30, 2019

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?

@micheljung micheljung changed the title postinst runs after prerm postinst runs after prerm when updating Jul 30, 2019
@Horcrux7
Copy link
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.

@Horcrux7
Copy link
Member

Horcrux7 commented Aug 7, 2019

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants