At work we use WiX for building installation packages. We want that installation of product X would result in uninstall of the previous version of that product on that machi
You might be better asking this on the WiX-users mailing list.
WiX is best used with a firm understanding of what Windows Installer is doing. You might consider getting "The Definitive Guide to Windows Installer".
The action that removes an existing product is the RemoveExistingProducts action. Because the consequences of what it does depends on where it's scheduled - namely, whether a failure causes the old product to be reinstalled, and whether unchanged files are copied again - you have to schedule it yourself.
RemoveExistingProducts
processes
elements in the current installation, matching the @Id
attribute to the UpgradeCode
(specified in the
element) of all the installed products on the system. The UpgradeCode
defines a family of related products. Any products which have this UpgradeCode, whose versions fall into the range specified, and where the UpgradeVersion/@OnlyDetect
attribute is no
(or is omitted), will be removed.
The documentation for RemoveExistingProducts
mentions setting the UPGRADINGPRODUCTCODE
property. It means that the uninstall process for the product being removed receives that property, whose value is the Product/@Id
for the product being installed.
If your original installation did not include an UpgradeCode
, you will not be able to use this feature.