我想根据安装的IIS有条件地部署文件。每次我部署它时,都会部署这两个功能。请帮忙。。。以下是代码片段的一部分。。。
<Product Id="*" Name="Patch Management" Language="1033" Version="1.0.0.0" Manufacturer="Start tech" UpgradeCode="739a025e-0758-4926-9528-2ad9a026e77a" Codepage="1252">
<Package Id="*" Compressed="yes" InstallScope="perMachine" Manufacturer="Star tech" Description="Server" Comments="(c)2016 Star tech" InstallPrivileges="elevated" AdminImage="yes"></Package>
<Property Id="IIS_MAJORVERSION">
<RegistrySearch Id="RS_IIS_MAJORVERSION_2" Root="HKLM" Key="SOFTWAREMicrosoftInetStp" Name="MajorVersion" Type="raw">
</RegistrySearch>
</Property>
<Feature Id="ServerFeature" Title="Server Feature" Level="1">
<ComponentGroupRef Id="EXETXT_CMPGRP" />
<Feature Id="ServerSite" Title="Server Feature" Level="1">
<ComponentGroupRef Id="IISWEB_CMPGRP"/>
<Condition Level="0"><![CDATA[IIS_MAJORVERSION="#5"]]]></Condition>
</Feature>
<Feature Id="ServerSiteIIS5" Title="Server Feature IIS5 " Level="1">
<ComponentGroupRef Id="IISWEB_CMPGRP_5"/>
<Condition Level="0"><![CDATA[IIS_MAJORVERSION<>"#5"]]]></Condition>
</Feature>
</Feature>
</Product>
我想这是因为您将特性嵌入了父特性下。
feature元素的InstallDefault属性有3个值。我认为默认值是followParent,所以无论其中的条件如何,这些功能都必须安装。我认为你可以通过将InstallDefault设置为源或本地来解决这个问题(未经我测试,如果一个有效,你必须测试并留下评论!)或者不要将这些功能嵌套在一起。除非你在安装UI中显示了一个功能树,否则无论你的所有功能是否在一起,对用户来说都没有什么区别。您还可以使用<功能组>要素