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

拥有回忆 提交于 2020-05-15 11:12:53

问题


We have a problem that a fie is not installed upon a major update

  • We have a major update with <MajorUpgrade Schedule="afterInstallInitialize"...
  • We an old component with 1 file (xyz.exe Version 12.34) from a external manufacturer
  • We have now a new file from a new manufacturer and with the same name (xyz.exe Version 2.34). The new file has a lower version number than the old one.
  • We created a new component in the install package and removed the old component (in fact we gave it a new guid)
  • Changing the name of the exe isn't possible, it would have to much influence upon documentation and internal functions.

On a normal installation everything is OK.

But what happens now on an update:

  • The installer starts.
  • And detects that the new component exists (xyz.exe) with a lower version, so it will not be installed.
  • the installer runs and removes the old component
  • But it doesn't install the new because it just detected that the component was already installed.
  • Doing a repair installation fixes the problem and the file is than again present.

Setting the KeyPath to the Component fixes the problem. But it seams wrong to me. The directory where this file is installed is the main installation directory.

How to force the installation of this component?


回答1:


Major Upgrade Downgrade: In order to overwrite binaries with higher version numbers on major upgrades there are a few options.

  • The preferred approach would be to use a companion file (third party files).
  • Or if you can: compile a new binary with a higher version number (for your own files).

REINSTALLMODE: The MSI property REINSTALLMODE can be used - but it has a number of side-effects:

Setup 1: Version 1.0.0 for a setup:

msiexec.exe /i Setup1.msi /qn

Setup 2: Version 2.0.0 for the major upgrade setup:

msiexec.exe /i Setup2.msi REINSTALLMODE=amus /qn

Several Problems: There are several issues with REINSTALLMODE that makes it an unsafe feature to use (try emus instead? See documentation - a little less brute force maybe). It is a shame that this setting applies to all features in the setup - that makes it very dangerous:

  • can downgrade shared files system-wide (if there are merge modules included - for example)
  • can cause inconsistent version estate since an old package can be installed after a newer one and downgrade only some of the shared files
  • can downgrade or wipe-out settings in non-versioned files (and registry settings)
  • can cause a significant increase in the number of requested reboots due to attempts to needlessly replace in-use files of the same version.
  • there are several further issues that are quite specific

Companion Files: A snippet below on how to use companion files in WiX:

<..>

<Component Id="MyFile.exe" Feature="Main">
  <File Id="MyFile.exe" Source="MyFile.exe"></File>
</Component>

<Component Id="MyFile_2.exe" Guid="{0EBDFD64-017B-428F-BB67-3D82EA2A99AF}" Feature="Main">
  <File Source="MyFile_2.exe" CompanionFile="MyFile.exe"></File>
</Component>

<..>

One-Line Summary: In the second component we point to the first component's file so that MyFile_2.exe will install whenever MyFile.exe is installed - regardless of versioning issues.


Hack Binary Version: An ugly, but effective option is to change the version of the binary file using Visual Studio to set a higher version number. Side effects are several:

  • you break digital signatures
  • you can create "version confusion"
  • there are risks involved writing a new binary from Visual Studio
  • you need to keep doing this for new versions
  • etc...

Move, Rename: If you can de-couple the new file from the old by renaming it or moving it you can work around the problem. If you get a new version again for the future, you might have to do this again. Clunky.

"Load From": Putting the file somewhere shared and load it from that specific location and removing the old copy from your installation folder. Could that work? This means the file could also be delivered by another setup at that location.


Version Lying: In Installshield there is a concept of being able to set a specific version number to a file. I am not sure how to implement that in WiX. There is also an "always overwrite option" that apparently sets a maximum value for the version so the existing file is always overwritten.


Some Links:

  • Why Windows Installer removes files during a major upgrade if they go backwards in version numbers
  • "Downgraded" MS dll disappears on upgrade - Windows Installer
  • Install a file regardless of version number with WiX
  • How to make better use of MSI files


来源:https://stackoverflow.com/questions/60827039/file-of-a-new-component-isnt-installed-because-there-was-an-old-component-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!