Conditional Components

Since I cannot set conditions for elements in a component, I have to separate elements from two separate components with conditional ones. From each example how to do this:

<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 are installed on each system and fail because there is only one of these users. What am I doing wrong here?

IIS_MAJOR_VERSIONcorrectly installed either on #6or #7. I also believe that I have the correct syntax because the start 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>

: , Windows ( ), . ? , .

+3
1

: , .

<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>

: . WiX.

+4

Source: https://habr.com/ru/post/1734624/


All Articles