问题
I have an Installshield project.
I added a major upgrade item and changed Product version , Product code and Package code.
After the installation with the new installer, the old version is still present (in Add / Remove)
I think it's related to the fact that my old version number was 1.0.4.23 and new one is 1.0.4.24 - is this a problem? Does major upgrade ignore such a small change in the version property?
In major upgrade common tab I chose Any earlier version
I remember doing this years ago with version numbers 1.1 and 1.2 and everything worked great, this is the main reason why I suspect the current issue is related to version numbers.
回答1:
I think it's related to the fact that my old version number was 1.0.4.23 and new one is 1.0.4.24 - is this a problem? Does major upgrade ignores such a small change in version?
Yes, only the first three fields of the version number are significant for major upgrade. The fourth field is simply ignored.
This is stated in a note at the Major Upgrades MSDN page.
If you want to trigger a major upgrade, your new version number must be 1.0.5.0 or greater.
Edit:
As Christopher Painter points out:
There is a way around this if you must use all four fields. You can create a custom action that does your own implementation of FindRelatedProducts and sets the action property with a ProductCode that RemoveExistingProducts then acts upon.
The custom action could be implemented like this:
- Call MsiGetProperty to get the UpgradeCode of your product.
- Call MsiEnumRelatedProducts() to enumerate all products that have the same UpgradeCode as your product.
- Call MsiQueryProductState() to verify that the product(s) returned by
MsiEnumRelatedProducts()are actually installed. I experienced some cases whereMsiEnumRelatedProducts()returned orphaned products that were no longer installed. So the code will be more robust by double-checking the install state withMsiQueryProductState(). - Call MsiGetProductInfo() with
INSTALLPROPERTY_VERSIONSTRINGas the argument for theszPropertyparameter to query the version of the installed product. Don't useINSTALLPROPERTY_VERSIONinstead, becauseINSTALLPROPERTY_VERSIONis derived from only the first three fields of the version number, the problem which we want to avoid. - When comparing version numbers, make sure you don't just compare the strings, but parse the strings into the fields that are separated by '.' and compare the fields individually.
- If you found a matching product that you want to replace, call MsiSetProperty() to set the ActionProperty to the ProductCode of this product that RemoveExistingProducts then acts upon.
来源:https://stackoverflow.com/questions/48042983/installshield-major-upgrade-doesnt-uninstall-old-version