WIX - Custom actions on Install but not on Uninstall or Upgrade - wix

I have a wix installer where we have several Custom Actions running, like the registration etc. However we only want these to run on the Install, not on the upgrade or the uninstall.
I've tried setting it to NOT Installed AND REINSTALL but that isn't working either.
Does anyone know what the correct property is when wanting to run certain apps via custom action only on Install and not on Upgrade or uninstall?
<InstallExecuteSequence>
<Custom Action="PosConfig.CustomAction" Before="StartServices"><![CDATA[NOT Installed AND NOT UPGRADINGPRODUCTCODE AND UILevel>3]]></Custom>
<Custom Action="Register.CustomAction" After="PosConfig.CustomAction">NOT Installed AND NOT UPGRADINGPRODUCTCODE </Custom>
<Custom Action="OPOSSelectorFirst.CustomAction" After="Register.CustomAction"><![CDATA[NOT Installed AND NOT UPGRADINGPRODUCTCODE AND &ProductFeature=3 AND Not OPOSDLLINSTALLED]]></Custom>
<Custom Action="OPOSSelectorUpdate.CustomAction" After="OPOSSelectorFirst.CustomAction"><![CDATA[NOT Installed AND NOT UPGRADINGPRODUCTCODE AND &ProductFeature=3 AND Not OPOSDLLINSTALLED]]></Custom>
</InstallExecuteSequence>
EDIT: Added my Custom Action Sequence.

NOT Installed AND REINSTALL can never be true at the same time. That would mean the application is not installed but is currently being re-installed. How would that work?
Schedule your custom action by using this condition instead:
NOT Installed AND NOT UPGRADINGPRODUCTCODE
This prevents it from being triggered on major upgrades.

UPGRADINGPRODUCTCODE is set during the RemoveExistingProducts action. Depending on your MajorUpgrade Schedule it may be too late. I've come to solution NOT Installed AND NOT WIX_UPGRADE_DETECTED.

Related

Upgrade triggers custom action

I have a custom action that meant for maintenance of installation:
<Custom Action="caPostMaintenanceConfiguration" Before="InstallFinalize">Installed AND NOT WIX_UPGRADE_DETECTED</Custom>
But this action is being executed during upgrade from original MSI during its uninstall. Is it a bug in Wix infrastructure? Is there a way to have control over that?
Assuming that the custom action is in the originally installed MSI as well as in your upgrade, then it will run during the uninstall of the older product. The condition will evaluate to true because the older product is still installed at the time you are uninstalling it, and WIX_UPGRADE_DETECTED won't be set during the uninstall.

Suppress custom action during upgrade for already released MSI

I have an already released MSI that has a custom action scheduled to run when UPGRADINGPRODUCTCODE is true. The action I released looks like this:
<Custom Action="DoThing" After="InstallFinalize" >
NOT REMOVE OR UPGRADINGPRODUCTCODE
</Custom>
The problem is I DON'T want it to run when my users upgrade. The action SHOULD have looked like this
<Custom Action="DoThing" After="InstallFinalize" >
NOT Installed
</Custom>
but unfortunately I didn't think this process through before I sent it out the door. So my question is what can I do? Is there any way to suppress this action in my next version's actions?
This is what patches are for. You are using WiX, so you could create a bundle that first installs the patch with the corrected condition then does the upgrade with the new MSI.

Upgrading with WiX Burn does not run upgrade custom actions on individual msi's

EDIT: My custom actions seem to be running well now, but I don't believe I changed any code. Do custom actions run in the order they appear in the wxs file or is their execution order arbitrary?
If I build my product.msi version 1.0.0 and install it, then rebuild it to be product.msi version 1.0.1 and upgrade it, the custom actions get called perfectly.
If I build my product.msi version 1.0.0 and put it into a burn installer version 1.2.0 and install it, then rebuild product.msi version 1.0.1 and put it into burn installer version 1.2.1 and upgrade it, my custom actions do not get called correctly.
Something about the burn bootstrapper is making custom actions not perform identically.
Here are my 4 custom actions. The final two are not being called when running the bootstrapper to update them.
<Custom Action='RemoveServiceWithProvidedBatch' After='InstallInitialize'>Installed</Custom>
<Custom Action='WaitForFileLocks' After='InstallInitialize'>Installed</Custom>
<Custom Action='InstallService' Before='InstallFinalize'>NOT REMOVE ~= "ALL"</Custom>
<Custom Action='MergeConfigFiles' Before='InstallFinalize'>NOT REMOVE ~= "ALL"</Custom>

Wix Burn Bundle - Must be Administrator

I've created a WIX Burn Bundle. In the Bundle I install .Net 4 (if its not installed) then 2 more .msi files. 1 is a third part msi the other a msi I created for my software using WIX. I need to be an Administrator on the machine to run these the .msi files.
I want the Burn bundle to not do anything if the user is not an administartor i.e. install nothing. In my product software I can easily do do using below - however I cant do this in the bundle. I've read lots of similar posts but just didnt find a working example for what I want to do.
<CustomAction Id="IsPrivileged" Error="You must be an Administrator to install [ProductName]." />
<InstallExecuteSequence>
<Custom Action='IsPrivileged' Before='LaunchConditions'>
Not Privileged
</Custom>
</InstallExecuteSequence>
You can use the bundle equivalent of launch conditions using Burn's built-in variables and WixBalExtension's Condition element:
<bal:Condition Message="You can't elevate.">
<![CDATA[Privileged <> 0]]>
</bal:Condition>
<bal:Condition Message="You're not elevated.">
WixBundleElevated = 1
</bal:Condition>

Uninstall add-on setup when uninstall the Main setup using Wix

I am using wix in my installer,
I need to uninstall add-on Setup while uninstall the Main setup,
I am using the below code in Main setup wix,
<CustomAction Id="UNINSTALL_ADDON" Return="asyncNoWait" Execute="immediate" ExeCommand="msiexec.exe /x [add-onProductID] /qn” Property="add-onProductID" />
Below code in InstallExecute Table
<Custom Action="UNINSTALL_ADDON" Sequence="1282">(REMOVE="ALL")</Custom>
I am using the below property
<Property Id=" add-onProductID" Value="NULL" />
I have read the add-on Property Id from registry and pass it set to add-onProductID using CustomAction while uninstall the main setup.
This won’t help. Could you please help me to solve the issue?
You cannot install or uninstall another MSI during InstallExecuteSequence because Windows Installer doesn't support simultaneous install processes.
A solution is to make sure that your custom action is scheduled after InstallFinalize action (it's sequence is greater than InstallFinalize).