我想将应用程序添加到不是默认IIS站点的现有IIS站点。这不是通常的请求,但在部署到Win 2008 SBS时需要,必须在“SBS Web应用程序”下移动MVC Web API应用程序才能正常工作。
在IIS中,我会在'SBS Web Applications'上点击鼠标右键>添加应用程序...并设置别名,应用程序池和物理路径。
Wix不允许我在IIS上设置这些属性:WebApplication,更多看起来我需要使用IIS:WebVirtualDir,但我不想或不需要这样做。我只需要将Physical Path属性指向我安装API的位置即可。
为什么我不能告诉WiX IIS:WebApplication Alias&根据IIS UI我想要的路径?
在我所做的所有WiX工作中,我认为这将是一件容易的事情。
注意:我想创建应用程序,我不想或不需要创建网站 - 它已经存在。
答案 0 :(得分:4)
您可以使用WIX实现指定的目标。我有更复杂的变体:安装到新网站或现有网站,用于IIS 6,IIS 7和IIS 7.5。
至于安装到现有网站, WIX根据SiteId识别网站。如果您的站点具有非自动生成的ID,则需要明确指定它,而不是在相应的字段中设置*。否则,siteId将根据其Description属性生成,因此您需要正确指定描述以引用现有站点。
以下是我的实现(我希望你能从中提取你需要的东西):
<PropertyRef Id="FRAMEWORKROOT"/>
<PropertyRef Id="SITE_INSTALL_MODE"/>
<PropertyRef Id="SITE_NAME"/>
<PropertyRef Id="SITE_PORT"/>
<PropertyRef Id="SITE_VIRT_DIR"/>
<PropertyRef Id="SITE_APP_NAME"/>
<PropertyRef Id="SITE_HEADER"/>
<PropertyRef Id="SITE_APP_POOL"/>
<PropertyRef Id="SITE_ID"/>
<Property Id="SITE_APP_NAME" Value="{ProductId}"/>
<iis:WebApplication Id="IIS6WebApp" Name="[SITE_APP_NAME]" WebAppPool="AppPool" >
<iis:WebApplicationExtension Verbs="GET,HEAD,POST" CheckPath="no" Script="yes" Executable="[FRAMEWORKROOT]v4.0.30319\aspnet_isapi.dll" />
</iis:WebApplication>
<iis:WebApplication Id="Iis7WebApp" Name="[SITE_APP_NAME]" WebAppPool="AppPool"></iis:WebApplication>
<iis:WebSite Id="ExistingWebSite" Description="[EXISTING_SITE_NAME]" SiteId="*">
<iis:WebAddress Id="ExistingSite_IIS7_Header_Binding" Port="[SITE_PORT]" Header="[SITE_HEADER]" />
</iis:WebSite>
<util:Group Id="IisUsersGroup" Name="[IisGroup]" Domain="[ComputerName]"/>
<DirectoryRef Id="SITE_INSTALLDIR">
<Component Id="AppPoolConfigure" Guid="YOURGUID-5549-48E8-B989-AFC61D279527" KeyPath="yes" Permanent="no">
<util:User Id="SiteUser" Domain="[APP_USER_DOMAIN]" Name="[APP_USER_NAME]" Password="[APP_USER_PASSWORD]" CreateUser="no" UpdateIfExists="no" RemoveOnUninstall="no">
<util:GroupRef Id="IisUsersGroup"/>
</util:User>
<iis:WebAppPool Id="AppPool" Name="[SITE_APP_POOL]" ManagedRuntimeVersion="v4.0" ManagedPipelineMode="integrated" Identity="other" User="SiteUser" />
</Component>
<Component Id="Iis6NewSiteConfigure" Guid="YOURGUID-8592-4E69-8D80-E42745307D7A" KeyPath="yes" Permanent="no">
<Condition><![CDATA[Installed OR (SITE_INSTALL_MODE = "NewSite" AND IISMAJORVERSION AND (IISMAJORVERSION = "#6"))]]></Condition>
<iis:WebSite Id="NewWebSite_IIS6" Description="[SITE_NAME]"
AutoStart="yes" StartOnInstall="yes" ConfigureIfExists="no"
Directory="SITE_INSTALLDIR" ConnectionTimeout="360" SiteId="[SITE_ID]"
DirProperties="WebDirProperties" WebApplication="IIS6WebApp">
<iis:WebAddress Id="Site_IIS6_Header_Bindings" Port="[SITE_PORT]" Header="[SITE_HEADER]" />
</iis:WebSite>
</Component>
<Component Id="Iis6ExistingSiteConfigure" Guid="YOURGUID-8ECB-4AC3-95B1-B7287D0AC903" KeyPath="yes" Permanent="no">
<Condition><![CDATA[Installed OR (SITE_INSTALL_MODE = "ExistingSiteNewVDir" AND IISMAJORVERSION AND (IISMAJORVERSION = "#6"))]]></Condition>
<iis:WebVirtualDir Id="Site_IIS6_VDir" Directory="SITE_INSTALLDIR" Alias="[SITE_VIRT_DIR]" WebSite="ExistingWebSite"
DirProperties="WebDirProperties" WebApplication="IIS6WebApp"/>
</Component>
<Component Id="Iis6ConfigExtentions" Guid="YOURGUID-55F2-48E3-8B08-E37BA5137D8D" KeyPath="yes" Permanent="yes">
<Condition><![CDATA[Installed OR (IISMAJORVERSION AND (IISMAJORVERSION = "#6"))]]></Condition>
<iis:WebServiceExtension Id="ExtensionASP4" Group="ASP.NET v4.0.30319" Allow="yes" File="[FRAMEWORKROOT]v4.0.30319\aspnet_isapi.dll" Description="ASP.NET v4.0.30319"/>
</Component>
<Component Id="Iis7NewSiteConfigure" Guid="YOURGUID-5DF6-4071-94F4-89D1EDAE8D90" KeyPath="yes" Permanent="no">
<Condition><![CDATA[Installed OR (SITE_INSTALL_MODE = "NewSite" AND IISMAJORVERSION AND (IISMAJORVERSION > "#6"))]]></Condition>
<iis:WebSite Id="WebSite_IIS7" Description="[SITE_NAME]"
AutoStart="yes" StartOnInstall="yes" ConfigureIfExists="yes"
Directory="SITE_INSTALLDIR" ConnectionTimeout="360" SiteId="[SITE_ID]"
DirProperties="WebDirProperties" WebApplication="Iis7WebApp">
<iis:WebAddress Id="NewSite_IIS7_Header_Binding" Port="[SITE_PORT]" Header="[SITE_HEADER]" />
</iis:WebSite>
</Component>
<Component Id="Iis7ExistingSiteConfigure" Guid="YOURGUID-FBBE-4379-8C7B-CDBD08EDCBA2" KeyPath="yes" Permanent="no">
<Condition><![CDATA[Installed OR (SITE_INSTALL_MODE = "ExistingSiteNewVDir" AND IISMAJORVERSION AND (IISMAJORVERSION > "#6"))]]></Condition>
<iis:WebVirtualDir Id="Site_IIS7_VDir" Directory="SITE_INSTALLDIR" Alias="[SITE_VIRT_DIR]" WebSite="ExistingWebSite"
DirProperties="WebDirProperties" WebApplication="Iis7WebApp"/>
</Component>
</DirectoryRef>
<ComponentGroup Id="IisSiteOrVDirCreate">
<ComponentRef Id="AppPoolConfigure"/>
<ComponentRef Id="Iis6NewSiteConfigure"/>
<ComponentRef Id="Iis6ExistingSiteConfigure"/>
<ComponentRef Id="Iis6ConfigExtentions"/>
<ComponentRef Id="Iis7NewSiteConfigure"/>
<ComponentRef Id="Iis7ExistingSiteConfigure"/>
</ComponentGroup>
<CustomAction Id="SetIisGroupToIUSRS" Property="IisGroup" Value="IIS_IUSRS" />
<CustomAction Id="SetIisGroupToWPG" Property="IisGroup" Value="IIS_WPG" />
<CustomAction Id="SetIisSiteUser" Property="IisSiteUser" Value="[APP_USER_DOMAIN]\[APP_USER_NAME]"/>
<InstallExecuteSequence>
<Custom Action="SetIisGroupToIUSRS" After="AppSearch">IISMAJORVERSION>="#7"</Custom>
<Custom Action="SetIisGroupToWPG" After="AppSearch">IISMAJORVERSION="#6"</Custom>
<Custom Action="SetIisSiteUser" Before="InstallInitialize">1</Custom>
</InstallExecuteSequence>