2

We have a software that has couple of executables inside. One of the executables is Windows service, and it doesn't change that often, usually we release many updates to the main executable, but the service version is same inside installer.

When service is installed first time or upgraded with newer version, we need to run custom action. We managed to solve first install part, but we don't know how to determine that version we're installing now is newer than one that already exists. Sort of if(newver > oldver) run custom action.

Thank you in advance - Jack

Jack Juiceson
  • 830
  • 4
  • 12
  • 24

2 Answers2

3

You can try using the upgrade rules of your package. More details here: How to implement WiX installer upgrade?

Rob Mensching (the second answer in the linked thread) shows an example for upgrade rules. You should first familiarize yourself with the Upgrade table and how upgrade rules work. There isn't an easy answer or a quick fix for this in WiX.

Basically, you should have 2 upgrade rules

  • the first sets a property when an older version is found
  • the second sets another property when a newer version is found

After that you can use the older versions property to condition your custom action. For example, if the property is named OLDERVERSIONFOUND the custom action condition can be:

OLDERVERSIONFOUND 

or something like

OLDERVERSIONFOUND > "1.0.0"
Community
  • 1
  • 1
Cosmin
  • 21,216
  • 5
  • 45
  • 60
  • @Cosmin - there is no simpler way to check if installed exe is older than newer one ? – Jack Juiceson May 24 '11 at 13:36
  • No, not really. A solution is to use a file search to determine if a specific version is installed, but this is not a very good approach. You would need to update the search each time you distribute a new version of the EXE. – Cosmin May 24 '11 at 13:54
  • @Cosmin - I don't really understand what I'm supposed to do. I read the link you gave. The upgrade works fine as we already have(I overwrites old files). Can you give a sample of how we do what you suggested in your answer in WIX? Thank you – Jack Juiceson May 24 '11 at 15:53
  • @Cosmin - when you say 'OLDERVERSION > "1.0.0"', does it mean that I will need to have hardcoded(1.0.0 for eg) version inside wix project? – Jack Juiceson May 25 '11 at 14:24
  • No. You can also use an installer property, for example OLDERVERSION > SPECIFIC_VERSION_PROPERTY – Cosmin May 26 '11 at 06:02
  • @Cosmin - What you mean by SPECIFIC_VERSION_PROPERTY ? When is it set ? I need a generic way for this to work, i.e. I don't want to be required edit anything when I have newer version of service. – Jack Juiceson May 26 '11 at 07:56
  • It was an example for a custom property which would contain a custom version string. They are all custom properties. There's nothing predefined here. If you want a generic approach, you can just check if the old versions property is set. If it is, then you are upgrading an older version and you can run the custom action. So the condition in my example can be just OLDERVERSIONFOUND. – Cosmin May 26 '11 at 08:24
2

Your best bet is to store the "service" version somewhere in the registry, search for that registry value during upgrade and run your CA if newver > oldver (and the CA should also update said registry value to newver)

Note that Custom Actions are (generally) an admission of failure. I always try to separate out the configuration portion of setup to a pre-install (for sysadmins doing deployment) or post-install (for interactive installations) step - often a separate executable.

Declarative installations with no custom actions are much more reliable - if you can figure out how to rewrite the service so that your custom action is no longer required, you'll be much better off in the long term (this doesn't help when you're under pressure to release now, but it's something to think of for future releases)

saschabeaumont
  • 22,080
  • 4
  • 63
  • 85