I found my answer. The markup I needed for the condition was this:
<Custom Action="ThingToDoIfFeatureSelected" Before="InstallFinalize">
<![CDATA[ADDLOCAL >< "MyFeatureName"]]>
</Custom>
The global variable ADDLOCAL holds a list of the features which will be installed locally. It is a simple comma separated string, so the ><
operator, which tests if the first string contains the second string, will return true if my feature is in the list. The CDATA prevents me from having to escape the ><
. Without it, ><
has to be written as ><
In my case, I have already limited the installation to local by adding this attribute to my feature: InstallDefault="local"
. So if my feature isn't in ADDLOCAL, it isn't being installed. If I hadn't limited the installation location, I would have to check every possible location, like this:
<Custom Action="ThingToDoIfFeatureSelected" Before="InstallFinalize">
<![CDATA[ADDLOCAL >< "MyFeatureName" OR ADDSOURCE >< "MyFeatureName" OR ADDDEFAULT >< "MyFeatureName"]]>
</Custom>
Alternate Solution: I found another simpler and more exact solution for my scenario which checks the "feature-action". The condition &MyFeatureName=3
means that this is the specific time when we are going to install this feature (it is not installed yet, and we are doing that installation now.) Likewise, the condition MyFeatureName=2
means that this is when we will uninstall this feature (it is installed now, and we are removing it).
More information on these conditions on this page.