Iis Wix MSI安装程序:设置为override=";时如何允许匿名身份验证;“否认”;在applicationHost.Config中

Iis Wix MSI安装程序:设置为override=";时如何允许匿名身份验证;“否认”;在applicationHost.Config中,iis,wix,wix3.11,Iis,Wix,Wix3.11,我有一个通过Wix MSI项目安装的web应用程序。web.config包含下面的身份验证节点。一切都正确安装,但安装后,我收到错误消息: “此路径不能使用配置节”。这是由于applicationHost.config中的配置锁定造成的 <system.webServer> <security> <authentication> <anonymousAuthentication enabled="false

我有一个通过Wix MSI项目安装的web应用程序。web.config包含下面的身份验证节点。一切都正确安装,但安装后,我收到错误消息: “此路径不能使用配置节”。这是由于applicationHost.config中的配置锁定造成的

<system.webServer>
    <security>
        <authentication>
            <anonymousAuthentication enabled="false" />
            <basicAuthentication enabled="true" />
            <windowsAuthentication enabled="false" />
        </authentication>
    </security>
</system.webServer>


如何在安装过程中覆盖applicationHost.config设置?在安装过程中,我确实安装了所需的Windows功能,但我是否缺少一项功能?

这是一个对我有效的解决方案,在InstallFinalize之前,通过自定义操作调用appcmd

<CustomAction Id="UnlockAnonymousAuthentication"
             Execute="deferred"
             Impersonate="no"
             Return="check"
             Directory="TARGETDIR"
             ExeCommand="[SystemFolder]inetsrv\appcmd unlock config /section:anonymousAuthentication" />

<CustomAction Id="UnlockBasicAuthentication"
             Execute="deferred"
             Impersonate="no"
             Return="check"
             Directory="TARGETDIR"
             ExeCommand="[SystemFolder]inetsrv\appcmd unlock config /section:basicAuthentication" />

<CustomAction Id="UnlockWindowsAuthentication"
             Execute="deferred"
             Impersonate="no"
             Return="check"
             Directory="TARGETDIR"
             ExeCommand="[SystemFolder]inetsrv\appcmd unlock config /section:windowsAuthentication" />

<InstallExecuteSequence>
    <Custom Action="UnlockAnonymousAuthentication" Before="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
    <Custom Action="UnlockBasicAuthentication" Before="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
    <Custom Action="UnlockWindowsAuthentication" Before="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
</InstallExecuteSequence>


希望这对其他人有所帮助。

这是一个适合我的解决方案,在安装完成之前,通过自定义操作调用appcmd

<CustomAction Id="UnlockAnonymousAuthentication"
             Execute="deferred"
             Impersonate="no"
             Return="check"
             Directory="TARGETDIR"
             ExeCommand="[SystemFolder]inetsrv\appcmd unlock config /section:anonymousAuthentication" />

<CustomAction Id="UnlockBasicAuthentication"
             Execute="deferred"
             Impersonate="no"
             Return="check"
             Directory="TARGETDIR"
             ExeCommand="[SystemFolder]inetsrv\appcmd unlock config /section:basicAuthentication" />

<CustomAction Id="UnlockWindowsAuthentication"
             Execute="deferred"
             Impersonate="no"
             Return="check"
             Directory="TARGETDIR"
             ExeCommand="[SystemFolder]inetsrv\appcmd unlock config /section:windowsAuthentication" />

<InstallExecuteSequence>
    <Custom Action="UnlockAnonymousAuthentication" Before="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
    <Custom Action="UnlockBasicAuthentication" Before="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
    <Custom Action="UnlockWindowsAuthentication" Before="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
</InstallExecuteSequence>


希望这对其他人有所帮助。

目前有一种方法可以直接使用WiX IIS扩展WebDirProperties元素来实现这一点:

类似的方法应该可以奏效。请注意,关键部分是
WebDirProperties
元素,该元素指定
AnonymousAccess=“yes”BasicAuthentication=“no”WindowsAuthentication=“no”
修改的 安装期间要更改的IIS属性

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
 xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension" >

    <Fragment>

    <!-- Install to default web site -->
    <iis:WebSite Id="DefaultWebSite" Description='Default Web Site'>
      <iis:WebAddress Id="AllUnassigned" Port="80" />
    </iis:WebSite>


    <!-- References the installation folder specified in the Product.wxs file under the INSTALLFOLDER -->
    <DirectoryRef Id="WEB_INSTALLFOLDER">

      <!-- Configure virtual dir -->
      <Component Id="VirtualDirectoryComponent"
             Guid="{INSERT-YOUR-OWN-GUID-2C27-427A-A7B1-DA4DBCC79117}"
             KeyPath="yes" >
        <iis:WebVirtualDir Id="VirtualDirectory"
                  Alias="[WEB_DIRECTORY_ALIAS]" Directory="WEB_INSTALLFOLDER"
                  WebSite="DefaultWebSite">
          <iis:WebDirProperties Id="VirtualDirectoryProperties"
             AnonymousAccess="yes" BasicAuthentication="no"
             WindowsAuthentication="no" />
          <iis:WebApplication
             Id="MyWebApplication"
             Name="MyWebApplication" />
        </iis:WebVirtualDir>
      </Component>

    </DirectoryRef>

    </Fragment>

</Wix>

目前有一种直接使用WiX IIS扩展WebDirProperties元素执行此操作的方法:

类似的方法应该可以奏效。请注意,关键部分是
WebDirProperties
元素,该元素指定
AnonymousAccess=“yes”BasicAuthentication=“no”WindowsAuthentication=“no”
修改的 安装期间要更改的IIS属性

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
 xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension" >

    <Fragment>

    <!-- Install to default web site -->
    <iis:WebSite Id="DefaultWebSite" Description='Default Web Site'>
      <iis:WebAddress Id="AllUnassigned" Port="80" />
    </iis:WebSite>


    <!-- References the installation folder specified in the Product.wxs file under the INSTALLFOLDER -->
    <DirectoryRef Id="WEB_INSTALLFOLDER">

      <!-- Configure virtual dir -->
      <Component Id="VirtualDirectoryComponent"
             Guid="{INSERT-YOUR-OWN-GUID-2C27-427A-A7B1-DA4DBCC79117}"
             KeyPath="yes" >
        <iis:WebVirtualDir Id="VirtualDirectory"
                  Alias="[WEB_DIRECTORY_ALIAS]" Directory="WEB_INSTALLFOLDER"
                  WebSite="DefaultWebSite">
          <iis:WebDirProperties Id="VirtualDirectoryProperties"
             AnonymousAccess="yes" BasicAuthentication="no"
             WindowsAuthentication="no" />
          <iis:WebApplication
             Id="MyWebApplication"
             Name="MyWebApplication" />
        </iis:WebVirtualDir>
      </Component>

    </DirectoryRef>

    </Fragment>

</Wix>


与相同?否,这是特定于WiX的,如何从安装程序执行此操作。与相同?否,这是特定于WiX的,如何从安装程序执行此操作。