Recently, I was looking at an MSI that installs a set of Visual Studio project templates. This MSI contains a condition in the LaunchCondition table that blocks users from installing the package on a system that did not have Visual Studio 2005 installed. This condition checks for a property that is set to true if an AppSearch finds the Visual Studio core IDE component installed on the system.
The problem with this logic is that I was blocked from uninstalling this MSI on my system when I uninstalled Visual Studio 2005 before trying to uninstall this MSI.
This scenario illustrates an important technique that should be used when authoring items in the LaunchCondition table of an MSI. In general, you should include a condition that checks the Installed property in addition to the condition that checks for the prerequisite product. Checking for the Installed property allows you to to see if the MSI is already installed and not block users from uninstalling if the prerequisite product has been uninstalled.
In this specific example, it does not make sense to block a user from uninstalling a set of Visual Studio project templates if Visual Studio has been uninstalled.
Rob Mensching described this scenario in more detail in the following 2 posts on his blog, and I highly recommend that you read these posts if you are a setup developer who is planning to use launch conditions to perform prerequisite checks:
- Creative Commons setup – conditioning the Office XP PIAs
- WiX v3 syntax for detecting the .NET Framework
Please note that there are a few corner cases where this behavior might not make sense. For example, if a product installs assemblies to the global assembly cache (GAC), it will need to express a dependency on the .NET Framework in order to be able to install assemblies. In that case, the product will not be able to remove assemblies from the GAC if the user has uninstalled the .NET Framework. However, in my experience, the instances where this type of dependency relationship exists is rare, so in nearly all cases, you should include a clause that checks the Installed property in your launch conditions.