【问题标题】:Using WiX to create an IIS virtual directory使用 WiX 创建 IIS 虚拟目录
【发布时间】:2009-03-09 03:27:32
【问题描述】:

我会在 WiX 邮件列表上问这个,但它似乎已关闭。

我有一个应用程序,它既是桌面应用程序,也是在本地运行的 Web 应用程序。我已经创建了几个基本的 WiX 安装程序,但还没有使用 IIS 扩展在 IIS 下创建虚拟目录。我还没有找到一个简单的例子来说明如何做到这一点。我需要做的就是创建虚拟目录,设置它的端口,并将它指向一个真实的目录,我正在使用安装程序的其余部分创建该目录。

如果机器上的 IIS 尚未启用,则奖励将是启用它,但我猜这是不可能的,而且对我来说也不是一个交易破坏者。

如果重要的话,这个安装程序只会在 Vista 机器上运行。

【问题讨论】:

    标签: windows iis iis-7 installation wix


    【解决方案1】:

    由于大卫提到的文章似乎丢失了,这里有一个例子。这也会在虚拟目录中创建一个应用程序。

    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
         xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
        <Product Id="6f2b2358-YOUR-GUID-HERE-aa394e0a73a2" Name="WixProject" Language="1033" Version="1.0.0.0" Manufacturer="WixProject" UpgradeCode="225aa7b2-YOUR-GUID-HERE-110ef084dd72">
            <Package InstallerVersion="200" Compressed="yes" />
    
            <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
    
            <!-- Reference existing site at port 8080 -->
            <iis:WebSite Id="My.Site" Description="My Site">
                <iis:WebAddress Id="My.Web.Address" Port="8080"/>
            </iis:WebSite>
    
            <Directory Id="TARGETDIR" Name="SourceDir">
                <Directory Id="ProgramFilesFolder">
                    <Directory Id="INSTALLLOCATION" Name="WixProject">
                        <Component Id="IIS.Component" Guid="{6FAD9EC7-YOUR-GUID-HERE-C8AF5F6F707F}" KeyPath="yes">
                            <iis:WebVirtualDir Id="My.VirtualDir" Alias="foo" Directory="INSTALLLOCATION" WebSite="My.Site">
                                <iis:WebApplication Id="My.Application1" Name="Web Application 1"/> 
                            </iis:WebVirtualDir>
                        </Component>
    
                    </Directory>
                </Directory>
            </Directory>
    
            <Feature Id="ProductFeature" Title="WixProject" Level="1">
                <ComponentRef Id="IIS.Component" />
            </Feature>
        </Product>
    </Wix>
    

    【讨论】:

      【解决方案2】:

      使用来自http://schemas.microsoft.com/wix/IIsExtension 命名空间的iis:WebVirtualDiriis:WebApplication

      我之前有一个类似的问题,我发现以下文章非常有用:Wix 3.0 Creating IIS Virtual Directory

      【讨论】:

      • 该博客的链接不再有效。您能否提供新的实时链接。谢谢。
      • 查看我的答案,我认为这是博客文章的代码。
      【解决方案3】:

      挖掘 Google 缓存(我认为现在已被 Google 清除)我认为以下是他的答案中包含的丢失的博客条目 David Pokluda 的代码。我必须做一些重新格式化才能把它变成 SO,如果它很难看,我很抱歉。

      <?xml version="1.0" encoding="UTF-8"?>
      <!--
      IMPORTANT
      1. need to add the schema iis.xsd to the property window
      2. add the following iis namespace
      3. add the Visual Studio reference WixIIsExtenion
      -->
      <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
      xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
        <Product Id="7b523f47-YOUR-GUID-HERE-fea6be516471" 
                 Name="Vince Wix 3 Web Service" 
                 Language="1033" 
                 Version="1.0.0.0" 
                 Manufacturer="Vince LLC" 
                 UpgradeCode="0a8c10df-YOUR-GUID-HERE-50b9ecdb0a41">
          <Package InstallerVersion="200" Compressed="yes" />
      
          <Media Id="1" Cabinet="WebAppWixProject.cab" EmbedCab="yes" />
      
          <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
              <Directory Id="WebApplicationFolder" Name="MyWebApp">
                <Component Id="ProductComponent" Guid="80b0ee2a-YOUR-GUID-HERE-33a23eb0588e">
                  <File Id="Default.aspx" Name="Default.aspx" Source="..\MyWebApp\Default.aspx" DiskId="1" />
                  <File Id="Default.aspx.cs" Name="Default.aspx.cs" Source="..\MyWebApp\Default.aspx.cs" DiskId="1"/>
                  <iis:WebVirtualDir Id="MyWebApp" Alias="MyWebApp" Directory="WebApplicationFolder" WebSite="DefaultWebSite">
                    <iis:WebApplication Id="TestWebApplication" Name="Test" />
                  </iis:WebVirtualDir>
                </Component>
              </Directory>
            </Directory>
          </Directory>
      
          <!--
          IMPORTANT
          Add a virtual directory to an existing web site
          If put it inside the Component, a new Web Site will be created and uninstall will remove it
          -->
          <iis:WebSite Id='DefaultWebSite' Description='Default Web Site' Directory='WebApplicationFolder'>
            <iis:WebAddress Id="AllUnassigned" Port="80" />
          </iis:WebSite>
      
          <Feature Id="ProductFeature" Title="Vince Wix 3 Web Service" Level="1">
            <ComponentRef Id="ProductComponent" />
          </Feature>
        </Product>
      </Wix>
      
      <!--
      IMPORTANT
      To get rid of light.exe location error, do the following on the Linker Tab:
      Set culture to: en-US
      Supress Schema Validation in the Advanced Button
      -->
      

      【讨论】:

        【解决方案4】:

        我不熟悉 WiX,但 IIS 6 和 7 都可以使用 WMI(Windows 管理规范)对象进行管理。我使用 PowerShell 和 C# 在 IIS 上创建网站、虚拟目录、权限等。您应该能够从大多数脚本环境中获得这些对象。

        【讨论】:

          【解决方案5】:

          上述 sn-ps 以不正确的方式使用 iis:WebAddress。如果您希望它适用于与名称和端口匹配的所有网站,则需要添加 IP="*"。如果在 IIS 中为网站分配了 ip 地址,则上面的示例在安装过程中失败(wix CA 一般不会找到它)

          Rant:在我看来,wix 很糟糕,原因有很多,这是一个很好的例子。如果缺少该属性,它将仅适用于具有默认 IP 的网站 - 这是多么不直观。 Wix 至少应该为缺少的 IP 元素发出警告。此外,默认 IP (localhost) 在 IIS 元数据库中表示为 *,同时在 wix 文件中 * 表示所有网站(不仅是 *)。所以它真的很混乱,根本不直观。

          【讨论】:

            猜你喜欢
            • 2010-09-20
            • 1970-01-01
            • 2016-10-06
            • 1970-01-01
            • 1970-01-01
            • 2012-02-02
            • 2023-04-04
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多