2013-02-05 61 views
5

我想將應用程序添加到不是默認IIS站點的現有IIS站點。這不是通常的要求,但是在部署到Win 2008 SBS時需要,MVC Web API應用程序必須在「SBS Web應用程序」下移動才能正常工作。如何使用WiX將應用程序添加到現有IIS站點

在IIS中,我會右鍵單擊'SBS Web Applications'> Add Application ...並設置別名,應用程序池&物理路徑。

Wix不允許我在IIS上設置這些屬性:WebApplication,進一步看起來我需要使用IIS:WebVirtualDir,但我不想或不需要這樣做。我只需要將物理路徑屬性指向我的API的安裝位置即可運行。

爲什麼我不能告訴WiX IIS:WebApplication別名&我希望根據IIS UI的路徑?

在我所做的所有WiX工作中,我會認爲這將是更容易做的事情之一。

注:我想創建應用程序,我不想或不需要創建網站 - 它已經在那裏。

回答

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> 
相關問題