Removing an MSI package in a bundle without including the source - wix

I have a WIX Bootstrapper Burn bundle which contains 4 MsiPackages and has been released in production. Our latest version of the bundle is to no longer ship one of the packages and should uninstall the package should it exist. What is the best way to uninstall the MsiPackage without providing the entire msi in the bundle?
I have tried:
Removing the PackageGroup from the chain entirely - This leaves the product behind.
Adding the MsiPackage and setting the installlevel to 0 - This needs a very large payload as the msi that is being removed is large.
I also tried using product search to find the state
<util:ProductSearch Id="AppX" UpgradeCode="XXXXXX-XXXX-XXXX-XXXX-XXXXXXXX" Result="state" Variable="APPXSTATE" />
but tried to hook it up to an ExePackage to run msiexec /x UpgradeCode but I figure is the wrong way to uninstall.
Whats the best way for me to purge msi with UpgradeCode X if it exists in this newer burn installer?
Thanks

Note: I am not aware of any auto-magic constructs to use in collaboration with util:ProductSearch to uninstall existing MSI
installations.
Upgrade Table: I assume the four different products have different upgrade codes "per family"? If so - and if you are positive it will never need to be installed again - then I suppose you could specify that it should be uninstalled via a major upgrade for one or more of the packages you will keep delivering. Note: It might be possible to uninstall even if all setups share the same upgrade code, but that requires a lot more care and testing.
This solution involves adding the upgrade code for the MSI you want to remove to the upgrade table of those MSI setups you want to preserve with a version range specified that will uninstall all "known prior editions". Technical details for how to do this can be found here: Adding entries to MSI UpgradeTable to remove related products. As stated it is enough to do so for one of the products that will remain, but you can do it for all of them to be sure. No errors should result if the product has already been uninstalled. I might want to set a tighter range than what is shown in that technical sample for the versions targeted.
ExePackage: It should be possible to uninstall as you have suggested by using an ExePackage instead. It could run msiexec.exe directly I suppose, or maybe launch a VBScript, Powershell script or even a batch file or your own EXE file compiled from C++ or C# (the latter with unfortunate runtime requirements). I have never tried this approach.
Please note that you do not uninstall by upgrade code in the fashion you do with msiexec.exe /x UpgradeCode - at least I have never been able to make that work (not tested for a while). Instead you need to uninstall via product code (How can I find the product GUID of an installed MSI setup?), OR you can use VBScript and MSI API automation to uninstall by using the Installer.RelatedProducts function and then kicking off uninstall that way as shown here: Powershell: Uninstall application by UpgradeCode. This is similar to what happens when Windows Installer processes the Upgrade Table. All releated products - those sharing the same upgrade code - are enumerated and you can handle them as you do so.
Some Links:
Powershell: Uninstall application by UpgradeCode
WIX (remove all previous versions)
Wix upgrade goes into maintenance mode and never does upgrade

Related

Wix installer, Windows control panel shows 2 entries and uninstall is greyed out

So I'm taking over a pre-existing installer project but I really don't know too much about Wix and installers in general so I am just asking to get an idea what areas in this installer I should look into.
I have this problem where the .msi generated by my Wix installer installs properly. But on Windows 10, the Apps & Features page shows 2 entries for my app as well both of the entries have the "Uninstall" button greyed out.
I'm pretty lost what part of the .wxs is in charge of what shows up in the Control Panel, any help will be appreciated.
WiX Quick-Start: WiX is not trival to learn - there is a learning curve, but it is not rocket science either. Maybe I can suggest this WiX quick start recommentations piece (chaotic, but upvoted - must be helpful). Particularly the "Hello World" section might be helpful - if you don't know WiX.
Answers: With regards to the specific questions:
Failed Major Upgrade: The two entries in Add / Remove Programs generally means a major upgrade has failed so there are now two installed versions of your product instead of one (a major upgrade is technically an uninstall of the old version and install of the new version - under the hood). Here is a long answer on the topic: Doing Major Upgrade in Wix creates 2 entries in Add/Remove Programs.
Embedded Setup.exe: It is also possible for an MSI to install a legacy-style setup.exe as part of its own installation. This could lead to several entries in Add / Remove Programs.
MajorUpgrade: To fix the major upgrade you need to look in your WiX sources, obviously. Normally people use the MajorUpgrade element to configure major upgrades (there are more detailed options using other elements). See separate section below for more on this.
Product Code: Whenever you have two versions of the same product installed, you have different product codes for them. To find the product codes, here are some suggestions: How can I find the product GUID of an installed MSI setup? Once you have the product codes you can uninstall via the msiexec.exe command line.
Uninstall: You can uninstall MSI files in a myriad of ways, here is a reference: Uninstalling an MSI file from the command line without using msiexec. Suggest you use msiexec.exe in section 3, as follows:
msiexec.exe /x {Product-Code}
WiX Major Upgrades: WiX introduced a "convenience element" to control major upgrade quite a while back. The idea was to make implementation easier. Here are some details: Majorupgrade or Upgrade ID which is preferred for Major upgrade?
Inlined:
<MajorUpgrade DowngradeErrorMessage="Can’t downgrade." />
As you can see the newer approach is much simpler to deal with, whilst the old one allows full flexibility. I don't know which approach your sources use.
Major Upgrade Technicalities: The key issues for a major upgrade is that the Upgrade Code remains stable (some ways to do it without, but leaving that for now). In addition you need a new product code, a bumped up product version (one of the first 3 digits) and a new package code. If any of these changes fail to be made you can get two entries in Add / Remove Programs (failed upgrade whilst running).
Some Links:
Doing Major Upgrade in Wix creates 2 entries in Add/Remove Programs
Old MajorUpgrade Style: How to implement WiX installer upgrade?
Adding entries to MSI UpgradeTable to remove related products
Choosing between upgrade types (minor, major, small) (Installshield content, MSI-generic, not WiX-specific)
Thanks to Stein Åsmul for his link to documentation. I was able to figure out why my msi was doing what it was doing.
The main .wxs was disabling the Remove with the property
<Property Id="ARPNOREMOVE" Value="1" />
So removing that allowed me to Uninstall from the Windows Control Panel again.
The reason why 2 entries were showing up in the Control Panel though was that we were adding a bunch of registry entries in the folder
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\
There's some reasons behind needing some registry entries here, but at least now that I know why I can hopefully work around them. Hopefully this helps anyone in the future that might run into this problem of duplicate entries from clean installs.

Remove other software on installation

When installing my software I need to take care another msi package is uninstalled before. Is this possible? Can burn do this for me?
MSI / Major Upgrade: You can add entries to the Upgrade table in one or all of the MSI files you install. Then the older / other MSI will be uninstalled before (or after) your MSI is installed. This is MSI's built in "major upgrade" feature intended to deliver upgrades for your own products, but you can uninstall any product you want that is MSI-based - even a competitive product - only if you are nuts, and do call legal first :-). Maybe see this description (related problem at least): Adding entries to MSI UpgradeTable to remove related products.
Burn: Burn can run EXE files that can initiate uninstall of pre-existing MSI files, but I would never choose this approach when you can use the above built-in MSI approach instead. I am not sure if you can call msiexec.exe directly via the ExePackage element of Burn, but you trigger the uninstall from within a custom made EXE file in a myriad of ways: Uninstalling an MSI file from the command line without using msiexec. It depends what your EXE is written in. If it is managed code, maybe use the DTF method (option 6 in the linked answer). If it is C++, maybe use the MSI API Win32 functions. See option 14 in the linked answer. I guess you can also chose to shell out to msiexec.exe (option 3). My advice: always go native code for deployment. Your setup must work on any machine, in any language, in any state and in any OS edition. There are many further variables. Minimal dependencies is the only cure.

Is there anyway to upgrade a .exe installed program with .msi without a double entry in ARP?

I am currently using WiX Toolset to build my installer. This tool is very nice but recently I encountered a problem. When I installed my program with .exe, then upgrade it with .msi, there is a double-entry in Add/Remove Program. Is there anyway to prevent the installer add double entry? Thanks!
It's not clear from your post if you have followed the rules for a major upgrade, such as use the same UpgradeCode, new ProductCode and PackageCode, increment ProductVersion in the first three fields, have upgrade logic in place in the MSI (such as major upgrade element). You'd need to supply your WiX source for these in the old and upgrade builds to see the differences. A verbose log would also help, installing the MSI with a command line that includes /l*vx [path to log file]
If those rules have been followed, the main reason for failure to upgrade is the one was per user and the other is per machine (or vice versa). One context will not upgrade the other. If this is the case the log will have an entry somewhere with FindRelatedProducts referring to an installed product in another context.
All this also assumes that the original install you did was MSI-based underneath the exe. If it was not, and it was some other install software that is not using an MSI file then there is no such thing as an automatic upgrade. You'd need to find some none-MSI way to uninstall the older product. A typical way is to find the UninstallString in the registry for that product and run it. Depending on the software used, that command can be parsed to add a silent option.

WiX installer - how can I remove installed application and re-install it at the same run

I have a custom installer based on WiX technology which is install several .vsix packages into Visual Studio.
If this packages are already installed, the installer offers to remove them. After the removal process is completed, the installer exits.
It's normal behaviour, but I need to offer the user re-install this packages (optionally) before exit. I mean optional mode to uninstall the previous version and install the new one (or the same) with a single run of the installer.
How to implement this in WiX ?
I suspect your custom installer could be made a little smarter. There are plenty of APIs (such as MsiQueryProductState) that will tell you if that exact ProductCode is installed, and ways to get the version (MsiGetProductInfo). My guess is that your custom installer is just firing off all the MSI installs without checking if they are already installed, hence the Remove prompts.
Your general plan should be to have some data available to your custom installer that it can use to find out what's already installed and what the versions are, and then compare these with what you are about to install. Use those APIs. If the product is already installed then skip the install. If you have a newer version (that you built with the WiX MajorUpgrade element) then just install it because it will replace the existing older one.
There's nothing I can think of in WiX that would automatically reinstall a product that your custom installer caused removal of by re-installing it and prompting the user to remove it, if that's what's going on.

MSI Installation issue

I am having an MSI file which copies a set of dll from it source to destination folder. While running the MSI the dll are copied to the destination folder also the MSI is installed in the system. I can see that in ADD or REMOVE programs.
Whenever there is a change in dll, i copying the new dll and building the MSI again. When i tries to run MSI in the same system i am getting error "Another version is already. Uninstall that version and proceed" something like that.
What i am doing until now is uninstalling the old one (MSI) and installing the new one.
But i want the MSI to update the older dll with the latest dll from the MSI instead of uninstalling and installing again.
Thanks in advance.
You can't just rerun the MSI to do an update. There's some background here, even if you are not using Visual Studio setups, and it's still relevant after all this time:
https://www.simple-talk.com/dotnet/visual-studio/updates-to-setup-projects/
To replace a single file, build a patch, an msp file. To upgrade the entire setup, including that Dll then use the WiX majorupgrade element, and that may be a lot easier than building a patch, especially if your setup is small and doesn't take long to install. Increase the file version of the Dll to make sure it gets replaced.
welcome to StackOverflow - it seems to be your first post. I would read this thread if I were you to get an overview of how to implement a WIX major upgrade: How to implement WiX installer upgrade?. Here is another thread (didn't read this one through): How to get WiX major upgrade working?
A major upgrade is essentially an automatic uninstall of the existing version and reinstall of a new version. This is the least error prone update mechanism in Windows Installer. It is the recommended approach to try at first - it works well. A minor upgrade - which is upgrading the existing install, is generally more difficult to get right in the beginning. A number of technical restrictions apply. Here is a very good summary of what is required for a minor upgrade to work (as well as other details): http://www.installsite.org/pages/en/msi/updates.htm
Check out this well known wix tutorial for upgrades and patches. And MSDN.