WymyslonyNick
WymyslonyNick

Reputation: 117

WiX - not executing custom action during update

I have two custom actions (immediate and deferrend). I would like to skipping actions during upgrade.

I tried:

 <Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.Version)" 
          Manufacturer="$(var.Manufacturer)" UpgradeCode="{GUID}">

    <MajorUpgrade DowngradeErrorMessage="Newer version is already installed." />

<Custom Action='CAa' After='InstallInitialize'>NOT Installed AND NOT PATCH</Custom>

and:

<Custom Action='CAa' After='InstallInitialize'>NOT Installed AND NOT UPGRADINGPRODUCTCODE</Custom>

Currently, actions starts during the update.

Upvotes: 1

Views: 1939

Answers (2)

PhilDW
PhilDW

Reputation: 20790

When you're doing a major upgrade with WiX MajorUpgrade the WIX_UPGRADE_DETECTED is set - see:

http://wixtoolset.org/documentation/manual/v3/xsd/wix/majorupgrade.html

so that is what you use in the upgrade install to detect that there is an older product installed. In other words it means that the new incoming install has detected an older version that is being upgraded.

UPGRADINGPRODUCTCODE is not the one to use. This property is set in the old product being upgraded and uninstalled so it knows the difference between being uninstalled and being upgraded, as the docs here say:

https://msdn.microsoft.com/en-us/library/aa372380(v=vs.85).aspx

"An application determines whether it is being removed by an upgrade or the Add or Remove Programs by checking UPGRADINGPRODUCTCODE."

Its value is the ProductCode of the incoming upgrade that is causing it to be removed.

Upvotes: 2

Stein &#197;smul
Stein &#197;smul

Reputation: 42226

These conditions are fiddly to get right - there are many options and modes for the InstallExecuteSequence (first time install, major upgrade install, minor upgrade install, maintenance install, uninstall, major upgrade uninstall sequence, patching, auto repair etc...). As I wrote in the comment above, you can try this PDF from Flexera.

No guarantees, but here is a proposal. You can try if this is what you want by showing message boxes from your CA (I can't test this using this lousy thin client, so it is a bit risky to try to answer without having done my own testing - please check carefully yourself):

Not Installed AND NOT PATCH AND NOT UPGRADINGPRODUCTCODE AND NOT REMOVE=~"ALL").

  • (NOT Installed) = run during first time installation
  • (NOT PATCH) = don't run during patching
  • (NOT UPGRADINGPRODUCTCODE) = don't run during a major upgrade uninstall
  • (NOT REMOVE=~"ALL") = don't run on uninstall

"Reference style table":

Upvotes: 2

Related Questions