다음을 통해 공유


What are Upgrade, Product and Package Codes used for?

Recently I am working with Windows Installer and think ProductCode, UpgradeCode and PackageCode are very basic but very important concepts, so I make a conclusion here for references. Both ProductCode and UpgradeCode can be viewed from Property table in MSI package, and PackageCode can be reviewed from View->Summary information if you view MSI through Orca (which is shipped with Windows SDK.)

What is UpgradeCode in the MSI package?

The upgrade code is the unique GUID of identifying a family of a product. That is, the same products with different versions have probably been shipped for a few releases. These products have different ProductCodes, but they are linked together by using SAME UpgradeCode. For example, assuming that we wrote a product called "Happy MSI" and this product only has one MSI package for deployment on client system. The first release of this product is actually the MSI package with name "version_1.msi", and the second release is "version_2.msi". Then, these two MSI must have same UpgradeCode. When users run "version_2.msi" on their system, the windows installer will use the UpgradeCode to decide if previous versions of this product are already present on the system. Installer API "MsiEnumRelatedProducts()" uses the UpgradeCode to query all the family products.

What is ProductCode in MSI Package?

The product code is the unique GUID of identifying an application or product release; In other words, different versions and languages of Product must have different product codes. https://msdn.microsoft.com/en-us/library/aa370854(VS.85).aspx. Also, ProductCode can be used to query feature state, and product state. For example,  installer API "MsiQueryFeatureStateEx()" and "MsiQueryProductState()", etc.

What is PackageCode in MSI Package?

Similar, the package code is the unique GUID identifying a particular Windows Installer package. Here, package mapps to a physical file with extension name ".MSI". Remember, a product consists of one or multiple (MSI) packages, and one package also can be shared among different products. The combination of ProductCode and PackageCode is used to determine if the users want to reinstall the product or not. I found the book "The Definitive Guide to Windows Installer" has the best explaination on this. There are four scenarios:

  • If you install same product (same ProductCode) from the same package (same PackageCode), it means you want to go to "repair" or "uninstall" mode.
  • If you install same product (same ProductCode) from the different package (different PackageCode), it is not allowed. You willl get message "Another version of this product is already installed", and you have to remove the existing installed product before you install the new one.
  • If you install different product (different ProductCode) from the package (same PackageCode), it would go into maintenance mode and ask for a repair or remove.
  • If you install different product (different ProductCode) from the package (different PackageCode), the installer will think it is a NEW product and let you go ahead.

Comments

  • Anonymous
    August 09, 2010
    Sir, As you explained 4 scenarios with Product and Package code, can you please give us scenarios with Product Code and Upgrade code..?

  • Anonymous
    October 04, 2011
    Me too, I need scenarios with Product and Package code.

  • Anonymous
    December 12, 2011
    Can you scenario for product upgrade

  • Anonymous
    January 22, 2012
    @Anay, @Apurva Upgrade code will be checked only when your msi does a FindRelatedProducts action. Windows Installer gives you the freedom to handle scenarios such as upgrade, downgrade, exit install etc. depending on the results of FindRelatedProducts. @David, This post already has Product and Package code scenarios. usually different builds of the same product used for testing will have different Package codes. Keep in mind that different builds aren't available to customers. When customer gets the RTM, it is unique in both product code and package code.

  • Anonymous
    March 26, 2012
    @BigMak2012, So does that mean that the msi will NOT do a FindRelatedProducts action if we are using deploying the same product (with same product code as earlier one that is already installed) but with a different package code? If this is the case, then how does the msi identify that an earlier version of software is already installed? If this is correct, then the scenario 2 above where the product code is same and package code is different and user triggers the msi, the msi package should go to maintenance mode and should ask for repair or uninstall action. This is because the underlying product is of same version and new package should merely imply new instructions for installation of same product. Also, my understanding was that typically, if we have an msi with different product code and same package code, then the msi would ask the user that a product of earlier version already exists and that the user can choose to uninstall or upgrade.

  • Anonymous
    December 07, 2012
    Thanks for the information about  <a href="www.flexerasoftware.com/.../resources.htm">msi packager</a>.  This answered my questions.

  • Anonymous
    January 08, 2014
    How to upgrade the older version of  MSI with newer version of MSI.

  • Anonymous
    October 18, 2015
    any one have solution ?? how to upgrade MSI version without uninstall  from control panel

  • Anonymous
    November 05, 2015
    It is worth nothing that package codes are not always Guids, especially when it comes to finding them in the windows registry. If you look at the uninstall key (HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall or its 32 bit equivalent) you can find things installed with package codes as 'Google Chrome' or things that are incomplete guids, or guids with and without surrounding braces.