Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Prevent IIS elements from being removed during upgrade

Mon Mar 25, 2019 1:41 pm

Hello,

If you need to prevent IIS elements from being removed during upgrade, here is what you need to do:
  1. Prevent IIS elements to overwrite the existing website
  2. Do not remove IIS elements during the uninstall triggered by an upgrade
An upgrade installation consists in two parts:
  1. the uninstall of the old product version
  2. the installation of the new product version
An upgrade process can be detected by using two properties:
  • OLDPRODUCTS - this property is set in the upgrading MSI if the package found an older version installed on the target machine
  • UPGRADINGPRODUCTCODE - this property is set in the MSI which is being upgraded if the package is uninstalled by a newer version
1) Prevent IIS elements to overwrite the existing website

This can be done through the Condition field from the Website Settings.
e.g.
IIS install condition.PNG
IIS install condition.PNG (22.92KiB)Viewed 171373 times


2) Do not remove IIS elements during the uninstall triggered by an upgrade
For this, you can go in the Table Editor page (available starting with the Enterprise edition) and condition the AI_IIsUninstall action from the InstallExecuteSequence table.
The condition can be something as this:

Code: Select all

( (VersionNT >= 500) AND (REMOVE = "ALL") ) AND ( NOT UPGRADINGPRODUCTCODE )
Unfortunately during the last uninstall from Control Panel, the IIS element will not be removed. The AdvInst references IIS elements through the ProductCode of the installers. Different versions have different ProductCodes, thus the IIS element will not be removed. For this, a custom action is required.

We recommend to use a PowerShell script code , specific cmdlet being available: The custom action needs to run When the system is being modified (deferred) and Run under the LocalSystem account with full privileges (no impersonation).

Also, please check the Use the 64-bit script so that 64-bit PowerShell be used on 64-bit machines.

Condition the custom action so that only be executed when the uninstall is not triggered by an upgrade:

Code: Select all

( (VersionNT > 501) OR (VersionNT = 501 AND ServicePackLevel >= 2) ) AND (NOT UPGRADINGPRODUCTCODE )

The sample project is attached to this thread, so if you are interested to take a look directly at my project, you are more than welcome to download the ZIP file.

Best regards,
Dan
Attachments
AdvInst Demo.zip
(4.69KiB)Downloaded 2506 times
IIS final uninstall CA.PNG
IIS final uninstall CA.PNG (56.59KiB)Viewed 171373 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Sample Projects”