alter_ego_dev2
Posts: 25
Joined: Wed May 10, 2023 4:09 pm

Could you please explain custom action order in different upgrade scenatious?

For example, an installer has custom action for both sequences (install and uninstall). It means that the installer executes some custom actions in install and executes other actions on app uninstall.

Case 1.
Current version (1.0) Upgrades/Order: "Uninstall old version first and then install new version".
Next version (2.0) has the same Upgrades/Order: "Uninstall old version first and then install new version".
If the current version is already installed and a user run the next version installer. What would be custom actions sequence?
I guess it would be:
current version (1.0) uninstall custom actions and then at some point next version (2.0) install custom actions. Right?

Case 2.
Current version Upgrades/Order: "Uninstall old version first and then install new version".
Next version has different Upgrades/Order: "Install new version first and then uninstall old version".
If the current version is already installed and a user run the next version installer. What would be custom actions sequence?
I guess it would be:
The next version (2.0) install custom actions and then at some point current version (1.0) uninstall? Or next version (2.0) unistall custom actions?
Liviu
Posts: 1325
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Could you please explain custom action order in different upgrade scenatious?

Hello,
Case 1.
Current version (1.0) Upgrades/Order: "Uninstall old version first and then install new version".
Next version (2.0) has the same Upgrades/Order: "Uninstall old version first and then install new version".
If the current version is already installed and a user run the next version installer. What would be custom actions sequence?
I guess it would be:
current version (1.0) uninstall custom actions and then at some point next version (2.0) install custom actions. Right?
Indeed, this is correct. In this case, the installer removes the old applications entirely before installing the new applications. That means the uninstall custom actions of the old version will be executed before installing the new version.

The Upgrade process is: Uninstall old version first and then install new version. Your custom actions will be executed like this:

1. First, from the new version (2.0) all of the custom actions scheduled before "RemoveExistingProducts" will be executed (if their condition is met).
2. Version 1.0 is uninstalled and also the custom actions scheduled on uninstall will be executed from the old version.
3. The installation continues with the new version.
Case 2.
Current version Upgrades/Order: "Uninstall old version first and then install new version".
Next version has different Upgrades/Order: "Install new version first and then uninstall old version".
If the current version is already installed and a user run the next version installer. What would be custom actions sequence?
I guess it would be:
The next version (2.0) install custom actions and then at some point current version (1.0) uninstall? Or next version (2.0) unistall custom actions?
In this case, the installer updates files before removing the old applications. Only the files being updated get installed during the installation. If the old application's removal fails, then the installer rolls back both the old application's removal and the new application's install.

Please note that some rules must be respected when using this option (as it is not how the Windows Installer would normally operate). More details on the Upgrades article.

Changing the upgrade order to install new version first and then uninstall old version is able to preserve old version in case the upgrade fails. The first version will be installed, and then the old version will be uninstalled (thus its uninstall custom action will be executed). The upgrade process performs the following actions:
    • Start installation of the new product
    • Check for matching components between products. Install the new components from new product.
    • Uninstall the components that are not used by the new product.
    Basically, what is written in the orange box from the above article means:
      • the new version of your installer will run
      • it will check the version of your files and only install the newer files. For instance, if in the first version (the one already installed) you have version 1.0 of an EXE/DLL and in the newer version (the one you are about to install), you have version 2.0 of the same EXE/DLL, then the 1.0 version will be replaced by the 2.0 version.
      After all the files are replaced, then the files from the older version are removed. For instance, if in version 1.0 you have a TXT file that no longer exists in version 2.0, it will be removed.

      Also, here, we must pay attention to the file versioning rules.

      For instance, if you want a non versioned file to be upgraded (e.g. a TXT file, a config file - INI, XML), then you will need to set the "Always overwrite" flag for it.

      You can check the Windows Installer Upgrades
      article for more details.

      Hope this helps!

      Best regards,
      Liviu
      ________________________________________
      Liviu Sandu - Advanced Installer Team
      Follow us: Twitter - Facebook - YouTube
      alter_ego_dev2
      Posts: 25
      Joined: Wed May 10, 2023 4:09 pm

      Re: Could you please explain custom action order in different upgrade scenatious?

      I'm sorry for the additional questions, but I need to double-check it.
      You wrote:
      Changing the upgrade order to install new version first and then uninstall old version is able to preserve old version in case the upgrade fails. The first version will be installed, and then the old version will be uninstalled (thus its uninstall custom action will be executed)

      Do you mean that the old version uninstall custom action will be executed?
      If the old version uninstall custom action has a problem and fails, can we somehow override with the new version custom action or exclude the action from the upgrade process?
      Liviu
      Posts: 1325
      Joined: Tue Jul 13, 2021 11:29 am
      Contact: Website

      Re: Could you please explain custom action order in different upgrade scenatious?

      Hello,

      I've replied to your other thread where you asked a similar question.

      Best regards,
      Liviu
      ________________________________________
      Liviu Sandu - Advanced Installer Team
      Follow us: Twitter - Facebook - YouTube

      Return to “Common Problems”