【问题标题】:Wix Installer - Preserve Application Pool User on UpgradeWix 安装程序 - 在升级时保留应用程序池用户
【发布时间】:2020-05-27 14:59:05
【问题描述】:

我有一个 WIX 安装程序,它使用 ApplicationPoolIdentity 作为默认身份创建应用程序池,如下所示。

<Component Id="MyConsoleAppPool" Guid="{my_guid_here}" KeyPath="yes" NeverOverwrite="yes" Win64="yes">
<iis:WebAppPool Id="MyAppPool"
                Name="My Web Console" 
                ManagedPipelineMode="Integrated"
                ManagedRuntimeVersion="v4.0" />
</Component>

我们的一些客户选择在安装后将应用程序池用户更改为不同的(自定义)IIS 用户。

在升级时,他们的应用程序池用户将被重置为默认的 ApplicationPoolIdentity。这让他们在每次升级时都头疼。

有没有办法保留现有的应用程序池用户,最好不需要重新输入用户密码?我们希望这在升级过程中静默发生。

注意:我们在 C# 中有一个帮助程序库,如果那里需要任何支持代码,可以通过 CustomAction 调用它。

【问题讨论】:

    标签: c# iis wix


    【解决方案1】:

    应用程序池被重置的原因是,由于它是从安装程序内部创建的组件,它会被完全删除并在升级时重新安装。

    我决定简单地引用应用程序池,而不是在“iis:WebAppPool”元素中构建应用程序池,如下所示,在任何 WIX 组件之外:

    <Fragment>
        <iis:WebAppPool Id="MyAppPool" Name="My Web Console"/>
    </Fragment>
    

    然后我创建了以下自定义操作来处理应用程序池的创建/删除:

    <CustomAction Id="CreateIISAppPool"
                      Directory="TARGETDIR"
                      ExeCommand="[SystemFolder]inetsrv\appcmd add apppool /name:&quot;My Web Console&quot; /managedRuntimeVersion:&quot;v4.0&quot; /managedPipelineMode:&quot;Integrated"
                      Execute="deferred"
                      Return="ignore"
                      Impersonate="no" />
    
    <CustomAction Id="DeleteIISAppPool"
                      Directory="TARGETDIR"
                      ExeCommand="[SystemFolder]inetsrv\appcmd delete apppool &quot;My Web Console&quot;"
                      Execute="deferred"
                      Return="ignore"
                      Impersonate="no" />
    

    以及排序,它表明应用程序池不会涉及任何升级场景:

    <InstallExecuteSequence>
          <Custom Action="DeleteIISAppPool" Before="CreateIISAppPool">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
          <Custom Action="CreateIISAppPool" Before="InstallFiles">(NOT UPGRADINGPRODUCTCODE) AND (NOT Installed) AND (NOT REMOVE="ALL")</Custom> 
          <!-- continue with rest of custom actions here -->
    </InstallExecuteSequence>     
    

    注意:此解决方案不考虑用户手动删除其应用程序池(错误或其他原因)。他们将需要卸载当前版本并重新安装以重新创建应用程序池。这可以通过添加另一个自定义操作来查找应用程序池来解决,如果找不到,请在升级时使用 UPGRADINGPRODUCTCODE 条件安装它。

    【讨论】:

      猜你喜欢
      • 2014-05-10
      • 2015-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-27
      • 1970-01-01
      • 2010-12-05
      相关资源
      最近更新 更多