1

I've added MajorUpgrade element to msi. Increased version, changed UpgradeCode, ProductId is the same. Here what it looks like

 <?define Config = "Release" ?>
 <?define ProductId = "{87FEDA58-2732-4BBA-9C1E-B7A9AE1A46F6}" ?>
 <?define UpgradeCode = "{B414C827-8D81-4B4A-B3B6-338C06DE3A11}" ?>
 <?define ProductName = "Some Product" ?>
 <?define Version = "2.0.0.0" ?>
 <?define Company = "Some Inc." ?>
 <?define Description = "Installs Some Product" ?>

In version 1.0.0.0 ProductId is different. MajorUpgrade is set like this

<MajorUpgrade 
      Schedule="afterInstallValidate"
      DowngradeErrorMessage="A newer version of [ProductName] is already installed." 
      AllowSameVersionUpgrades="yes" />

During the upgrade it successfully identifies previous version on FindRelatedProducts stage

Action start 22:31:06: FindRelatedProducts.
MSI (s) (38:78) [22:31:06:557]: PROPERTY CHANGE: Adding WIX_UPGRADE_DETECTED property. Its value is '{3E786878-358D-43AD-82D1-1435ADF9F6EA}'.
MSI (s) (38:78) [22:31:06:557]: PROPERTY CHANGE: Adding MIGRATE property. Its value is '{3E786878-358D-43AD-82D1-1435ADF9F6EA}'.
MSI (s) (38:78) [22:31:06:557]: Doing action: AppSearch
MSI (s) (38:78) [22:31:06:557]: Note: 1: 2205 2:  3: ActionText 
Action ended 22:31:06: FindRelatedProducts. Return value 1.

RemoveExistingProducts starts the uninstallation RemoveFolderEx removes some folders and RemoveExistingProducts stage returns code 1 (success right?). But it doesn't remove entries in registry. Product is still there. Components not remove. Here is the log.

Action start 22:35:25: RemoveExistingProducts.
MSI (s) (38:78) [22:35:25:190]: Note: 1: 2205 2:  3: Error 
MSI (s) (38:78) [22:35:25:190]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 23 
MSI (s) (38:AC) [22:35:25:190]: Resetting cached policy values
MSI (s) (38:AC) [22:35:25:190]: Machine policy value 'Debug' is 0
MSI (s) (38:AC) [22:35:25:190]: ******* RunEngine:
           ******* Product: {3E786878-358D-43AD-82D1-1435ADF9F6EA}
           ******* Action: 
           ******* CommandLine: **********
MSI (s) (38:AC) [22:35:25:205]: Note: 1: 2265 2:  3: -2147287035 
MSI (s) (38:AC) [22:35:25:205]: End dialog not enabled
MSI (s) (38:AC) [22:35:25:205]: Original package ==> C:\Windows\Installer\bd684.msi
MSI (s) (38:AC) [22:35:25:205]: Package we're running from ==> C:\Windows\Installer\bd684.msi
MSI (s) (38:AC) [22:35:25:221]: APPCOMPAT: Uninstall Flags override found.
MSI (s) (38:AC) [22:35:25:221]: APPCOMPAT: Uninstall VersionNT override found.
MSI (s) (38:AC) [22:35:25:221]: APPCOMPAT: Uninstall ServicePackLevel override found.
MSI (s) (38:AC) [22:35:25:221]: APPCOMPAT: looking for appcompat database entry with ProductCode '{3E786878-358D-43AD-82D1-1435ADF9F6EA}'.
MSI (s) (38:AC) [22:35:25:221]: APPCOMPAT: no matching ProductCode found in database.
MSI (s) (38:AC) [22:35:25:221]: Machine policy value 'DisablePatch' is 0
MSI (s) (38:AC) [22:35:25:221]: Machine policy value 'AllowLockdownPatch' is 0
MSI (s) (38:AC) [22:35:25:221]: Machine policy value 'DisableLUAPatching' is 0
MSI (s) (38:AC) [22:35:25:221]: Machine policy value 'DisableFlyWeightPatching' is 0
MSI (s) (38:AC) [22:35:25:237]: APPCOMPAT: looking for appcompat database entry with ProductCode '{3E786878-358D-43AD-82D1-1435ADF9F6EA}'.
MSI (s) (38:AC) [22:35:25:237]: APPCOMPAT: no matching ProductCode found in database.
MSI (s) (38:AC) [22:35:25:237]: Transforms are not secure.
MSI (s) (38:AC) [22:35:25:237]: Command Line: UPGRADINGPRODUCTCODE={87FEDA58-2732-4BBA-9C1E-B7A9AE1A46F6} CLIENTPROCESSID=2520 CLIENTUILEVEL=3 MSICLIENTUSESEXTERNALUI=1 REMOVE=ALL 
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding PackageCode property. Its value is '{0C30C985-B880-4BEF-90B5-52ED8736B108}'.
MSI (s) (38:AC) [22:35:25:237]: Product Code passed to Engine.Initialize:           '{3E786878-358D-43AD-82D1-1435ADF9F6EA}'
MSI (s) (38:AC) [22:35:25:237]: Product Code from property table before transforms: '{3E786878-358D-43AD-82D1-1435ADF9F6EA}'
MSI (s) (38:AC) [22:35:25:237]: Product Code from property table after transforms:  '{3E786878-358D-43AD-82D1-1435ADF9F6EA}'
MSI (s) (38:AC) [22:35:25:237]: Product registered: entering maintenance mode
MSI (s) (38:AC) [22:35:25:237]: Determined that existing product (either this product or the product being upgraded with a patch) is installed per-machine.
MSI (s) (38:AC) [22:35:25:237]: MSI_LUA: Nested installation UAC elevation tracks that of parent (is not elevated)
MSI (s) (38:AC) [22:35:25:237]: Product {3E786878-358D-43AD-82D1-1435ADF9F6EA} is admin assigned: LocalSystem owns the publish key.
MSI (s) (38:AC) [22:35:25:237]: Product {3E786878-358D-43AD-82D1-1435ADF9F6EA} is managed.
MSI (s) (38:AC) [22:35:25:237]: MSI_LUA: Credential prompt not required, user is an admin
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding ProductState property. Its value is '5'.
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding ProductToBeRegistered property. Its value is '1'.
MSI (s) (38:AC) [22:35:25:237]: Package name retrieved from configuration data: 'aep_monolith.msi'
MSI (s) (38:AC) [22:35:25:237]: Note: 1: 2205 2:  3: Error 
MSI (s) (38:AC) [22:35:25:237]: Note: 1: 2262 2: AdminProperties 3: -2147287038 
MSI (s) (38:AC) [22:35:25:237]: Machine policy value 'DisableMsi' is 1
MSI (s) (38:AC) [22:35:25:237]: Machine policy value 'AlwaysInstallElevated' is 0
MSI (s) (38:AC) [22:35:25:237]: User policy value 'AlwaysInstallElevated' is 0
MSI (s) (38:AC) [22:35:25:237]: Product {3E786878-358D-43AD-82D1-1435ADF9F6EA} is admin assigned: LocalSystem owns the publish key.
MSI (s) (38:AC) [22:35:25:237]: Product {3E786878-358D-43AD-82D1-1435ADF9F6EA} is managed.
MSI (s) (38:AC) [22:35:25:237]: Running product '{3E786878-358D-43AD-82D1-1435ADF9F6EA}' with elevated privileges: Product is assigned.
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding UPGRADINGPRODUCTCODE property. Its value is '{87FEDA58-2732-4BBA-9C1E-B7A9AE1A46F6}'.
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding CLIENTPROCESSID property. Its value is '2520'.
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding CLIENTUILEVEL property. Its value is '3'.
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding MSICLIENTUSESEXTERNALUI property. Its value is '1'.
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding REMOVE property. Its value is 'ALL'.
MSI (s) (38:AC) [22:35:25:237]: Machine policy value 'DisableAutomaticApplicationShutdown' is 0
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding MsiRestartManagerSessionKey property. Its value is '7dad24bc7ce3134db335b2318702e12c'.
MSI (s) (38:AC) [22:35:25:237]: RESTART MANAGER: Session opened.
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding MsiSystemRebootPending property. Its value is '1'.
MSI (s) (38:AC) [22:35:25:237]: TRANSFORMS property is now: 
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding PRODUCTLANGUAGE property. Its value is '1033'.
MSI (s) (38:AC) [22:35:25:237]: PROPERTY CHANGE: Adding VersionDatabase property. Its value is '301'.

Here is the ending of it

MSI (s) (38:78) [22:39:08:694]: Note: 1: 2205 2:  3: Error 
MSI (s) (38:78) [22:39:08:694]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 16 
MSI (s) (38:78) [22:39:08:694]: Note: 1: 2205 2:  3: Error 
MSI (s) (38:78) [22:39:08:694]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 21 
MSI (s) (38:78) [22:39:08:694]: Doing action: ProcessComponents
MSI (s) (38:78) [22:39:08:694]: Note: 1: 2205 2:  3: ActionText 
Action ended 22:39:08: RemoveExistingProducts. Return value 1.

And at the very end I get

MSI (s) (38:78) [22:42:18:570]: Windows Installer installed the product. Product Name: Some Product. Product Version: 2.0.0.0. Product Language: 1033. Manufacturer: Some Inc.. Installation success or error status: 0.

Could you help me please? I ran out of any ideas.

Vlad Gudikov
  • 103
  • 1
  • 7
  • I'm guessing that you misspoke about changing the ProductID/ProductCode. During a major upgrade you'll want to change this value and normally keep the value of the UpgradeCode the same. It might be helpful to checkout Microsoft's documentation on Windows installer upgrades. https://learn.microsoft.com/en-us/windows/win32/msi/major-upgrades – Doc Aug 11 '20 at 11:51
  • @Doc as far as I understand Product Id and the ProductCode is the same thing as it says here https://stackoverflow.com/questions/10330534/in-wix-where-is-the-productcode-specified so I changed Product ID. UpgradeCode is the same for both versions. Thanks for answering) – Vlad Gudikov Aug 11 '20 at 12:00
  • Please check this: [Installshield / Flexera MSI Update Types Table Overview](https://docs.flexera.com/installshield26helplib/helplibrary/MajorMinorSmall.htm) to see the differences between the different MSI upgrade types easily. – Stein Åsmul Aug 11 '20 at 12:42
  • @SteinÅsmul I think I've done everything correctly for major upgrade – Vlad Gudikov Aug 11 '20 at 13:03
  • Yes, you probably have it. [Here is a list of common major upgrade problems](https://stackoverflow.com/a/56991527/129130). And a few other links: [1](https://stackoverflow.com/a/59722068/129130), [2](https://stackoverflow.com/a/48761048/129130), [3](https://stackoverflow.com/a/51803320/129130). – Stein Åsmul Aug 11 '20 at 13:24
  • Product ID and PRoductCode are *not* the same thing. In fact, in WiX it's just better you set Product/@Id="*" (let it auto-generate; there's no practical reason to set it) and don't author Package/@Id (it will auto-generate; there's even less practical reasons to set that). – Heath Aug 12 '20 at 02:13
  • Interestingly the WMI class [Win32_Product](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa394378(v=vs.85)) uses the term ***"IdentifyingNumber"*** for the property that shows the ***"Product Code"***. Might be good to know. [How can I find the product GUID of an installed MSI setup?](https://stackoverflow.com/q/29937568/129130). Adding a link to [Win32_product and PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/samples/working-with-software-installations?view=powershell-7). – Stein Åsmul Aug 13 '20 at 09:03

1 Answers1

1

The easiest way to author a major upgrade is to not author as many GUIDs as possible. See this example. Don't even author component GUIDs if you don't have to, i.e. if they contain more than one resource - but try to avoid that.

For example, this makes an easy major upgrade:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="Sample Product" Language="1033" Version="1.0.0.0" Manufacturer="Heath Stewart" UpgradeCode="f10d913e-7669-4962-aa3f-963425ecf10b">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate />

    <Feature Id="ProductFeature" Title="SampleProduct" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="SampleProduct" />
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component>
        <File Source="$(var.SampleApp.TargetPath)" />
      </Component>
      <Component>
        <RegistryKey Root="HKLM" Key="Software\[Manufacturer]\[ProductName]">
          <RegistryValue Name="InstallDir" Type="string" Value="[INSTALLFOLDER]" />
          <RegistryValue Name="Version" Type="string" Value="[ProductVersion]" KeyPath="yes" />
        </RegistryKey>
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

Notice that Product/@Id="*" is authored, and there's no package ID. There are really no good reasons to hardcode them, nor should you. Only the Product/@UpgradeCode should be hardcoded, and only if the root install folder is the same. You don't want to change the folder when the component GUIDs remain the same, of vice versa. It creates all sorts of shared component issues, which I've blogged a lot about in the past: https://devblogs.microsoft.com/setup/tag/shared-components/

Heath
  • 2,986
  • 18
  • 21