tags:

views:

30

answers:

1

Since I cannot put conditions on elements in a component, I have to separate the items into two separate components conditional. From every example, this is how to do it:

<Component Id="IIS7Webhost" Guid="482EC8D7-2DA2-48e6-A11D-6CAB3C5973E8">
  <Condition><![CDATA[IIS_MAJOR_VERSION >= "#7"]]></Condition>
  <CreateFolder>
    <Permission User="IUSR" GenericAll="yes"/>
  </CreateFolder>
</Component>
<Component Id="IIS6Webhost" Guid="51C65FAC-84B7-43d1-A230-DD9AE66B5D99">
  <Condition><![CDATA[IIS_MAJOR_VERSION <= "#6"]]></Condition>
  <CreateFolder>
    <Permission User="IUSR_[ComputerName]" GenericAll="yes"/>
  </CreateFolder>
</Component>

But BOTH of these components install on every system and fail because only one of those users exists. What am I doing wrong here?

IIS_MAJOR_VERSION is set correctly to either #6 or #7. Also I believe I have the syntax correct because the launch condition works correctly:

<Condition Message="Internet Information Services 5, 6, or 7 must be installed.">
  <![CDATA[Installed OR (IIS_MAJOR_VERSION >= "#5" AND IIS_MAJOR_VERSION <= "#7")]]>
</Condition>

Edit: It appears both do NOT install, but Windows Installer checks the existence of each user (while ignoring the condition) before it goes about creating directories. Is there a way to skip this check? I already know one of those users will not exist.

A: 

Found solution: Conditional custom actions that set properties.

<CustomAction Id="SetWebuserIIS7" Return="check" Property="WEBUSER" Value="IUSR" />
<CustomAction Id="SetWebuserIIS6" Return="check" Property="WEBUSER" Value="IUSR_[ComputerName]" />
<CustomAction Id="SetDomainIIS7" Return="check" Property="WEBDOMAIN" Value="" />
<CustomAction Id="SetDomainIIS6" Return="check" Property="WEBDOMAIN" Value="[ComputerName]" />

<InstallExecuteSequence>
  <Custom Action="SetWebuserIIS6" After="InstallInitialize"><![CDATA[IIS_MAJOR_VERSION <= "#6"]]></Custom>
  <Custom Action="SetWebuserIIS7" After="SetWebuserIIS6"><![CDATA[IIS_MAJOR_VERSION >= "#7"]]></Custom>
  <Custom Action="SetDomainIIS7" After="SetWebuserIIS7"><![CDATA[IIS_MAJOR_VERSION >= "#7"]]></Custom>
  <Custom Action="SetDomainIIS6" After="SetDomainIIS7"><![CDATA[IIS_MAJOR_VERSION <= "#6"]]></Custom>
</InstallExecuteSequence>

<!-- in component -->
<CreateFolder>
  <Permission User="[WEBUSER]" Domain="[WEBDOMAIN]" GenericRead="yes" GenericExecute="yes"/>
</CreateFolder>

Credit: Source. That right there is WiX for ya.

Nick Whaley