简体   繁体   中英

How can a wix installer downgrade merge-module files during a major version upgrade?

We have an installer that consumes a merge module. The newest version of the merge module includes downgrades to some files. When using the installer to upgrade from an earlier version we are having problems downgrading these files.

Initially the files from the merge module were being removed and not re-installed, but after reading wix major upgrade not installing all files I set Schedule='afterInstallFinalize' on the MajorUpgrade element. This resulted in the files with the newer versions being retained.

How can we change either our installer or the merge module so that these files are downgraded during an upgrade?

Well, in my opinion, the best way to approach this issue is to sequence the standard action "RemoveExistingProducts" to before CostInitialize standard action. Be aware that this scheduling is not in accordance with the Microsoft recommendation at :

https://msdn.microsoft.com/en-us/library/windows/desktop/aa371197(v=vs.85).aspx

So, when you try to build your msi package, you might have to end up suppressing ICE error messages ,which if not suppressed, might prevent you from building. There is an easy way to suppress ICE error messages in Wix . You can do that in the Visual studio IDE as well as when using the candle.exe to compile your .wxs project. The Wix documentation will give you enough details about this.

If you are wondering if its ok to go against the Microsoft recommended placement for RemoveExistingProducts, take a look at :

Downgrade File in MajorUpgrade

FWIW, I've talked to MS support in the past about having REP before costing to make upgrades work successfully, and at that time they said it was ok, while pointing out that it's also before MigrateExistingFeatures so if you migrate features during upgrades there'll be an issue.

What this means is that , if you have multiple features in your msi package and you want the exact same set of features to be upgraded by your upgrade package, then this approach might not work. However, if you just have a single feature in your msi package, then this approach will work.

Also, be aware that placing RemoveExistingProducts outside of InstallInitialize and InstallFinalize has other consequences, in case there is an error during your upgrade, as RemoveExistingProducts is not transacted.

What might happen is that , RemoveExistingProducts will uninstall your old application and then the upgrade process starts the installation of your newer version of your product. However, at this point of time, if there happens to be an error installing your newer version of your product, then the upgrade rolls back and then you will be left with no version of the product on your system.

http://blogs.msdn.com/b/heaths/archive/2010/04/09/major-upgrades-with-shared-components.aspx

-The other option is to make use of REINSTALLMODE property. You will author this property in your property table with a value of emus REINSTALLMODE = emus.

If emus doesnt work, try with amus. using amus is fraught with risks and should be avoided for the most part, except in exceptional circumstances.

https://msdn.microsoft.com/en-us/library/aa371182(v=vs.85).aspx

However, exercise caution here again.

REINSTALLMODE are caller properties and are usually set by the person performing the installation and hence its not a good practice to author this in the Property table.

However, there might be exceptional situations such as yours which might require you to take this approach.

-The other option i was thinking was to change the component GUIDs of the components in your Merge module. However doing so would only work if the following condition is met:

-All the consumers of your merge module have RemoveExistingProducts sequenced very early in the upgrade cycle ie they follow a method of ugprade where the older product is uninstalled and a newer product is installed. So this might lead to re-sequencing of RemoveExistingProducts in all of your consumers.

Reason being, assume for a moment that you change the component GUID in the present version of the merge module and then you rebuild the latest version of the installer using this merge module. If RemoveExistingProducts is sequenced later in the upgrade cycle ie after InstallFinalize, then it's a violation of windows installer component rules. You have two products installing the same file to the same location but with different component GUId's. Hence, its absolutely critical that if this approach is followed, RemoveExistingProducts is sequenced very early in the upgrade cycle.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM