"forcing an upgrade of a file that is modified during its initial installation" Code Answer


newer answers: 1) companion files, 2) file version hack using visual studio, 3) moving the file to another installation path, 4) variations of reinstallmode, 5) "version lying", etc... all kind of options, most of which are not ideal:

  • file of a new component isn't installed because there was an old component with the same file

  • how to explicitly remove dll during majorupgrade using wix toolset

below is an older answer. i don't think option 2 works properly anymore:

there are many ways - none are ideal.

1: you can use a companion file to force update of the file in question. provided the companion file specified always gets updated, this may be the way to go. essentially this means that you link the non-versioned file to the version update logic of its companion file (files are updated together). i have never used this in wix, but i think it's as easy as adding the companionfile attribute to a file element and point to the id of the file you want to "version follow". inside the msi file it will look something like this:

2: you can use a custom action to delete the file before file costing (or better yet, rename it to a backup format). the problem is that if the setup fails the file will be missing. if you rename the file instead of deleting you can put it back in case the setup fails via a rollback custom action. sometimes i use the removefile table to remove files on install, but depending on the sequencing specified in installexecutesequence this may not work (deletion must happen before msi does file costing).

3: then there is the sledgehammer approach: set reinstallmode = amus to force overwrite all files regardless of version. i shouldn't even mention this since it is horribly dangerous (you can end up overwriting system files, or on newer windows versions trigger a nasty runtime error as files are protected). use it only for dev testing, and don't think it is a quick fix. it causes more problems than it solves.

as a variation, an acceptable approach may be to set the reinstallmode to emus (replace older and same version files). this can help if you don't want to increment the version numbers but keep rebuilding your binaries - as is the case in a lot of .net. my guess is this will cause a whole new range of problems though - most significantly binary different but version identical files in the wild if you use it for public releases - a deployment smell if ever there was one. as a qa/dev only approach it could work though. but seriously, why bother? just auto-increment the build version of the binaries and the problem is solved reliably.


  • how to explicitly remove dll during majorupgrade using wix toolset
By laserany on April 27 2022

Answers related to “forcing an upgrade of a file that is modified during its initial installation”

Only authorized users can answer the Search term. Please sign in first, or register a free account.