Reputation: 707
I'm trying to get a conditional component to work.
However it's not working at all so I'm stumped.
I've got the following blobs of code:
The feature is defined like this:
<Feature Id="MainFeature" Level="1" Title="!(loc.FEATURE.MAINFEATURE.TITLE)"
Description="!(loc.FEATURE.MAINFEATURE.DESCRIPTION)" Display="collapse">
<ComponentRef Id="MainExecutable" />
<ComponentRef Id="pmd" />
</Feature>
and the component is defined as
<Component Id="MainExecutable" Guid="*">
<Condition><![CDATA[(&MainFeature = 3) AND NOT (!MainFeature = 3)]]></Condition>
<File Id="MainExecutableFile" Name="SampleApp.exe"
Source="..\ProductBuild\sampleFile.txt" KeyPath="yes">
<Shortcut Id="MainExecutableStartMenu" Directory="ProgramMenuDir"
Name="!(loc.APPNAME)" WorkingDirectory="INSTALLDIR"
Icon="icon.ico" IconIndex="0" Advertise="yes"/>
<Shortcut Id="MainExecutableDesktop" Directory="DesktopFolder"
Name="!(loc.APPNAME)" WorkingDirectory="INSTALLDIR"
Icon="icon.ico" IconIndex="0" Advertise="yes" />
</File>
</Component>
However the files are never installed!
Upvotes: 2
Views: 18837
Reputation: 35831
A Component
Condition
is not evaluated at a time that the feature states have been determined. Thus, your Condition
will never evaulate correctly (as you've found).
However, I'm not sure you need the Condition
. Components will only be installed when their parent Feature is set to be installed as well. It seems like your Condition
is trying to replicate the built in behavior (but can't due to the above).
Upvotes: 7