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.