MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: /MacroCfg[Next]: MapUserDir
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Source Code->Commands->MajorUpgrade

The "MajorUpgrade" Command

This command allows you to define what products should be removed when the installation of this product begins (applications to be uninstalled are identified by their "UpgradeCode" property and perhaps other attributes such as their version number or language).

You can use this command instead of or in addition to specifying the "List of UpgradeCodes" in the ".ver" file.

A major update ensures that you will not have to worry about what is "allowed" in "minor upgrades" etc, each of your builds can work exactly the same way without requiring any knowledge of what was done for the last install...

Most people will probably use the "Guid.UpgradeCode" keyword to assign a unique upgrade code to their product.

This command takes these parameters:

When looking for the appropriate configuration for an item such as "VERSION_MIN" the configuration is searched for from (in order):

  1. Was the information supplied as a parameter on this command?

  2. Where it searches next depends on how the upgrade code was supplied in the unnamed parameter:

    1. {7EF333CB-3BB9-457D-831E-8482E50F2999}_VERSION_MAX
      The configuration is searched by upgrade code (when it is passed directly).

    2. SomePdfReader(v1.00.0002)_VERSION_MAX
      The configuration is searched by macro name when it is passed.

    3. FromVbVariable_VERSION_MAX
      The configuration is searched by vbscript variable name when it is passed.

    This is as described for the "CONFIG" parameter above.

If you don't understand the above then as always look at the debug output.


;--- The HTML (summary row) Related Options ---------------------------------
#( '<br>'

    Any products with these
       upgrade codes are
    automatically removed when
      installing this package


;--- Define UpgradeCode for product "ProductX" (major version 1) ------------
#define ProductX.Version1               {11111111-1111-1111-1111-111111111111}
#define ProductX.Version1_VERSION_MIN   1.00.0000
#define ProductX.Version1_VERSION_MAX   1.99.9999

;--- Define UpgradeCode for product "ProductY" (any version) ----------------
#define ProductY                        {11111111-1111-1111-1111-333333333333}

;--- Define UpgradeCode via vbscript variable -------------------------------
#define FromVbVariable_PROPERTY                          MY_UPGRADE_CODE_FROM_VB_VARIABLE         ;;Override property name for this GUID
#define {21AB9EAB-A161-45EA-9272-704EEC8175F9}_PROPERTY  MY_UPGRADE_CODE_21AB9EAB
dim FromVbVariable : FromVbVariable ="{99999999-9999-9999-9999-999999999999}"

<$MajorUpgrade "{21AB9EAB-A161-45EA-9272-704EEC8175F9} ProductX1.00.0002 ProductX1.00.0003 {22222222-2222-2222-2222-222222222222} =FromVbVariable" comment="test this command">
<$MajorUpgrade "{66666666-A161-45EA-9272-666666666666}" VERSION_MIN="1.23.4567" comment="Test passing some 'Upgrade' table parameters">

The UpgradeCodes (version file keyword) can be passed GUIDS in the same way.

Major Upgrade Supporting Code

The following code is an extract from "COMPANY.MMH" which:

  1. Handles the current msi's upgrade code.

  2. Handles any extra upgrade codes as specified by the "UpgradeCodes" product keyword in the ".ver" file.

  3. Moves the "RemoveExistingProducts" action to ensure that the found products are completely removed before the install continues.
   ;--- Look for older/newer versions of the same package (group) -----------
   #define UpgradeCode_PROPERTY    UC_OURSELVES     ;;Use this property in "Upgrade" table entry
   <$MajorUpgrade "=UpgradeCode" Comment=^We upgrade any version of this product!^>               ;;Use value in VB variable

   ;--- Any EXTRA upgrade codes to be handled? ------------------------------
   #if ['<$ProdInfo.UpgradeCodes>' <> '']
       <$MajorUpgrade "<$ProdInfo.UpgradeCodes>" comment="Defined by .ver file (KeyWord: UpgradeCodes)">

   ;--- Install MSI AFTER complete uninstallation of older ------------------
   #define? COMPANY_RemoveExistingProducts_HOOK_BEFORE_MOVING
   #define? COMPANY_RemoveExistingProducts_HOOK_AFTER_MOVING
   #define? COMPANY_RemoveExistingProducts_SEQ                 InstallValidate-InstallInitialize
        ;--- Allow easy overiding/removal of this step ----------------------
        #define? COMPANY_MOVE_RemoveExistingProducts
        <$Table "InstallExecuteSequence">
            ;--- Move to desired location -----------------------------------
            dim RepSeq : RepSeq = GetSeqNumber("InstallExecuteSequence", "<$COMPANY_RemoveExistingProducts_SEQ>", 1)
            <$Row Action="RemoveExistingProducts" *Sequence="RepSeq">

Optionally Generating a Random Upgrade code

While I don't neccessarily recommend this the following code place into a common header file will modify the normal behavour so that you can still supply a fixed GUID (via version file or macro) but if not supplied a new unique GUID will be randomly generated for you:

;--- If Upgrade GUID not supplied want a random one -------------------------
#( '<?NewLine>'

   ;--- Simple validation ---------------------------------------------------
       #error ^Currently don't support use of a "COMPANY_UPGRADE_CODE_QUALIFIER"...^

   ;--- Generate a random GUID unless we already have one -------------------
   #RexxVar @@UcMacName = '<$VER_PRODINFO_GUID_PREFIX>UpgradeCode'
   dim UpgradeCode                                 ;;VBS variable
   #if  Defined(@@UcMacName) = 'N'
        ;--- Generate Random GUID -------------------------------------------
        #info "UpgradeCode GUID randomly generated..."
        UpgradeCode = GuidMake("UpgradeCode")      ;;VBS to generate random GUID
        ;--- Use value supplied (probably in ".VER" file --------------------
        #info "UpgradeCode: <$[@@UcMacName]>"
        UpgradeCode = "<$[@@UcMacName]>"           ;;GUID supplied as literal
        VbsReturnGuid "UpgradeCode", UpgradeCode   ;;Ensure HTML report can access this information
   <$Property "UpgradeCode"   *Value="UpgradeCode">   ;;Use GUID "calculated" above


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: /MacroCfg[Next]: MapUserDir

MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday August 13 2017 at 2:39pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.