wix installer / Create web-site and assign the new or exisiting web app pool

这一生的挚爱 提交于 2019-12-23 13:32:05

问题


i try create a new web-site using wix installation. it's ok there is no problem but i cannot assign a new or existing web app pool to new web-site. iis:website tag does not contains WebAppPool attribute. How can i assign web app pool to web-site. You can see my code bellow.

thanks for helping.

        <Component Id="WEB_SITE_CONFIGURE_COMPONENT" Guid="{35087032-D049-48C8-BCAD-1FEFD0C06A25}" NeverOverwrite="yes" Shared="yes" Permanent="yes" Transitive="yes">
          <Condition><![CDATA[WEBSITE_INSTALLTYPE<>2]]></Condition>
          <CreateFolder Directory="WEBSITE_FOLDER"/>
          <iis:WebSite Id="WEB_SITE" Description="[WEBSITE_NAME]" SiteId="*" Directory="WEBSITE_FOLDER" ConfigureIfExists="yes" AutoStart="yes" StartOnInstall="yes">
            <iis:WebAddress Id="AllUnassigned" Port="[WEBSITE_PORT]" />            
          </iis:WebSite>
          <RegistryValue Root="HKLM" Key="$(var.DefaultRegistryKey)" Name="ConfigSite" Value="1" Type="string"></RegistryValue>
        </Component>        

        <Component Id="WEBAPP_POOL_CONFIGURE_COMPONENT" Guid="{316738A6-26A2-4C14-9AB9-B2066E3FA288}" KeyPath="yes" Permanent="yes" Transitive="yes">
          <Condition><![CDATA[(WEBSITE_INSTALLTYPE=0) OR (USE_CUSTOM_WEBSITE_FOLDER=1)]]></Condition>          
          <iis:WebAppPool Id="APP_POOL" Name="[WEBAPP_POOL_NAME]" ManagedPipelineMode="Classic" ManagedRuntimeVersion="v4.0"/>
          <RegistryValue Root="HKLM" Key="$(var.DefaultRegistryKey)" Name="ConfigPool" Value="1" Type="string"></RegistryValue>
        </Component>

        <Component Id="WEPAPP_CONFIGURE_COMPONENT" Guid="{F95B024E-B6B6-4E6C-AC35-9B1086FC3521}" Transitive="yes">
          <Condition><![CDATA[(WEBSITE_INSTALLTYPE<>2) AND ((WEBSITE_INSTALLTYPE=0) OR (USE_CUSTOM_WEBSITE_FOLDER=1))]]></Condition>
          <iis:WebVirtualDir Id="VIRTUAL_DIR" Alias="[WEB_APP_NAME]" Directory="WWW_FOLDER" WebSite="WEB_SITE">
            <iis:WebApplication Id="WEB_APP" Name="[WEB_APP_NAME]" WebAppPool="APP_POOL"/>            
          </iis:WebVirtualDir>
          <RegistryValue Root="HKLM" Key="$(var.DefaultRegistryKey)" Name="ConfigVirtualDir" Value="1" Type="string"></RegistryValue>
        </Component>

回答1:


With the help of the following articles I have come up with a working installer in which a new AppPool can be created or an existing AppPool can be selected.

  1. Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1
  2. Web Application Installer in WiX
  3. WiX and DTF: Using a Custom Action to list available web sites on IIS
  4. Installing a Web Application to an Existing IIS Website using Wix3

In short: Create a Website element in your Product element:

<Product>
    <iis:WebSite Id="SelectedWebSite" Description="[WEBSITE_DESCRIPTION]" Directory="INSTALLFOLDER" SiteId="[WEBSITE_ID]">
      <iis:WebAddress Id="AllUnassigned" Port="80" />
    </iis:WebSite>
</Product>

Create an Include WebSites.wxi with the following content:

<?xml version="1.0" encoding="utf-8"?>
<Include>
  <Property Id="WEBSITE_DESCRIPTION">
    <RegistrySearch Id="WebSiteDescription" Name="WebSiteDescription" Root="HKLM" Key="SOFTWARE\!(loc.CompanyName)\[ProductName]\Install" Type="raw" />
  </Property>
  <Property Id="WEBSITE_ID">
    <RegistrySearch Id="WebSiteID" Name="WebSiteID" Root="HKLM" Key="SOFTWARE\!(loc.CompanyName)\[ProductName]\Install" Type="raw" />
  </Property>
  <Property Id="WEBSITE_PATH">
    <RegistrySearch Id="WebSitePath" Name="WebSitePath" Root="HKLM" Key="SOFTWARE\!(loc.CompanyName)\[ProductName]\Install" Type="raw" />
  </Property>
  <Property Id="WEBSITE_VD">
    <RegistrySearch Id="WebSiteVD" Name="WebSiteVD" Root="HKLM" Key="SOFTWARE\!(loc.CompanyName)\[ProductName]\Install" Type="raw" />
  </Property>
  <CustomTable Id="AvailableWebSites">
    <Column Id="WebSiteID" Category="Identifier" PrimaryKey="yes" Type="int" Width="4"/>
    <Column Id="WebSiteDescription" Category="Text" Type="string" PrimaryKey="no"/>
    <Column Id="WebSitePath" Category="Text" Type="string" PrimaryKey="no" Nullable="yes"/>
    <Row>
      <Data Column="WebSiteID">0</Data>
      <Data Column="WebSiteDescription">Dummy</Data>
      <Data Column="WebSitePath"></Data>
    </Row>
  </CustomTable>
</Include>

Create the CustomAction described here.

Create a wxs file with your AppPool:

<?xml version="1.0" encoding="UTF-8"?>
<Wix 
  xmlns="http://schemas.microsoft.com/wix/2006/wi" 
  xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" 
  xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
    <Fragment>
    <Component Id="WebVirtualDirComponent" Guid="PUT-GUID-HERE" Directory="INSTALLFOLDER" KeyPath="yes">
      <iis:WebAppPool 
        Id="YourAppPoolName" 
        Name="[VD][WEBSITE_ID]" 
        ManagedRuntimeVersion="v4.0" 
        IdleTimeout="0" 
        RecycleMinutes="0" 
        ManagedPipelineMode="integrated"/>
      <iis:WebVirtualDir Id="VDir" Alias="[VD]" Directory="INSTALLFOLDER" WebSite="SelectedWebSite">
        <iis:WebApplication Id="NotizBrowserWebApp" WebAppPool="YourAppPoolName" Name="[VD][WEBSITE_ID]" />
        <iis:WebDirProperties Id="NotizBrowserProps" AnonymousAccess="no" WindowsAuthentication="yes" DefaultDocuments="-" Execute="yes" Script="yes" Read="yes"/>
      </iis:WebVirtualDir>
    </Component>
    </Fragment>
</Wix>



回答2:


Late answer, but hopefully someone will be benefited with this.

You don't need a CustomAction to make this work.

It is simple like this:

<Component Id="WebSite" Guid="PUT-YOUR-GUID-HERE">
    <CreateFolder/>
    <iis:WebSite Id="WebSite" Directory="WebSiteRoot" Description="[WEBSITEDESCRIPTION]" >
        <iis:WebApplication Id="WebSiteApplication" Name="[WEBSITEDESCRIPTION]" WebAppPool="MyAppPool" />
    </iis:WebSite>
    <iis:WebAppPool Id="MyAppPool" Name="[APPPOOLNAME]" ManagedRuntimeVersion="v4.0"/>
</Component>

You need to update the "Internal" WebApplication of the WebSite.

You don't need to have the "WebSite Description" and "WebApplication Name" equal, but that will help you to understand what is going on.



来源:https://stackoverflow.com/questions/18389208/wix-installer-create-web-site-and-assign-the-new-or-exisiting-web-app-pool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!