Home > Net >  How to keep track of the previous version number in MSI WIX
How to keep track of the previous version number in MSI WIX

Time:02-03

I'm trying to add a functionality of upgrading my SQL database using one single upgradeScripts.sql file in which I need to hardcode the previous build version and before running the upgrade scripts I need to check If the upgradeScripts.previous build number matches the LocalDB.build number. If don’t match then don’t execute the upgrade scripts. So how can I hardcode the previous build number in WIX itself?

CodePudding user response:

Not sure you can do it via wix, but you can store build number in registry and use custom actions to check it:

  1. Add custom action
  2. In that custom action try to read value from registry
  3. If there's some, run your script with values. you can do it from custom action too, or modify script and run it via sql script
  4. After successful installation add new version to registry. You can do it via CA with OnExit="success" - it will run only on successful installation. Here's example with cancel, just change it to success. Or just add custom action after your scrit run. It's easier.

CodePudding user response:

I prefer to create a table in the database itself and use that. It's all too easy to backup/restore a database and install/uninstall/reinstall/upgrade who knows what version for the MSI version to matter. What's important is that the current MSI being installed can create a net new database and migrate a previous schema to the current version. I do this for simple databases that need to be installed on clients silently.

Alternatively, for servers/more complex database, I like to move this out of the installer and into the application. For example Azure DevOps server does this with an Admin Tool. This way your developers have all of their favortite tools available to them without struggling with WiX and MSI.

  • Related