2

I have Googled and found these resources:

But I am still not sure if what I want to add is correct syntax or not. Is this valid?

<Custom Action="CAInstall" After="CAInstall.SetCustomActionData">NOT Installed or REINSTALL="ALL" or NOT (REMOVE="ALL")</Custom>

The part I am thinking to add is the last condition:

or NOT (REMOVE="ALL")
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Bohn
  • 26,091
  • 61
  • 167
  • 254

2 Answers2

2

A WiX Setup project (or any candle and light compilation with a source file with a Product root element) builds a Windows Installer package (.msi). Windows Installer is the actual engine and is part of Windows.

So, that part of the syntax is Windows Installer's Conditional Statement Syntax.

This is valid syntax

NOT Installed or REINSTALL="ALL" or NOT (REMOVE="ALL")

It could also be written as

NOT Installed or REINSTALL="ALL" or REMOVE~="ALL"

(Whether it identifies the scenarios for your situation, I don't know.)

Tom Blodget
  • 20,260
  • 3
  • 39
  • 72
  • Yes my goal is to kind of make an "UNINSTALL" first when user wants to INSTALL. Basically management told us we don't want to tell the user to uninstall, but we are just telling them to install !! but they already have the software on their system so hopefully this way first they go to install it, it will uninstall and then install ? – Bohn Aug 16 '18 at 13:04
2

Condition: If you assign that condition to a custom action it appears it will run in all installation modes except manual uninstall or uninstall initiated by a major upgrade. So that would be fresh install, repair, modify, self-repair and minor upgrade. Note on what happens on major upgrade below.

Note that there are a few special installation modes or rather sub-modes that are rarely properly tested: suspended install - essentially installations resumed after reboot (AFTERREBOOT and RESUME properties), and there are rollback and commit modes that may run unless disabled - and there could be more. These are "aspects" of the other modes - in other words they can or will be invoked as appropriate depending on circumstances.

Here Be Dragons: You should be aware that the action will still run during the major upgrade process though, just not from the old setup that is being uninstalled. Rather it will run from the new setup that is installing the updated application (next version) - provided you haven't updated the condition in the new setup when it comes along.

Confucius Says: This "run from new version" or "run from old version" issue can be very confusing, and it is made worse by the fact that the sequencing (order) of uninstall versus install can be switched around. In other words the old version might be uninstalled before the new version is installed, or it might be uninstalled after the new version has been installed. This could affect what files are present on disk if you try to access them (among other things). They could be uninstalled already by the time your setup tries to access them. It all depends on how you configure things as a whole.


Custom Actions: Custom actions are difficult. Here is my propaganda against them: Why is it a good idea to limit the use of custom actions in my WiX / MSI setups? This is not to say that they are not needed - they are at times, but you must avoid them at all cost if you can. There is also a little check list for unwanted custom actions in the first section here: How do I avoid common design flaws in my WiX / MSI deployment solution?. Essentially you should never use custom actions for these purposes: to install services, to install to the GAC, to run .NET installer classes, to install prerequisites, to run batch files or similar.


Some Links:

Community
  • 1
  • 1
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Yes my goal is to kind of make an "UNINSTALL" first when user wants to INSTALL. Basically management told us we don't want to tell the user to uninstall, but we are just telling them to install !! but they already have the software on their system so hopefully this way first they go to install it, it will uninstall and then install ? – Bohn Aug 16 '18 at 12:56