Wix 安装程序 - 在升级时保留应用程序池用户
Wix Installer - Preserve Application Pool User on Upgrade
我有一个 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 调用它。
应用程序池被重置的原因是,由于它是从安装程序内部创建的组件,它将被完全删除并在升级时重新安装。
我没有在 "iis:WebAppPool" 元素中构建应用程序池,而是决定按如下方式简单地引用应用程序池,在任何 WIX 组件之外:
<Fragment>
<iis:WebAppPool Id="MyAppPool" Name="My Web Console"/>
</Fragment>
然后我创建了以下自定义操作来处理应用程序池 create/remove:
<CustomAction Id="CreateIISAppPool"
Directory="TARGETDIR"
ExeCommand="[SystemFolder]inetsrv\appcmd add apppool /name:"My Web Console" /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"
Execute="deferred"
Return="ignore"
Impersonate="no" />
<CustomAction Id="DeleteIISAppPool"
Directory="TARGETDIR"
ExeCommand="[SystemFolder]inetsrv\appcmd delete apppool "My Web Console""
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 条件的升级中安装它。
我有一个 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 调用它。
应用程序池被重置的原因是,由于它是从安装程序内部创建的组件,它将被完全删除并在升级时重新安装。
我没有在 "iis:WebAppPool" 元素中构建应用程序池,而是决定按如下方式简单地引用应用程序池,在任何 WIX 组件之外:
<Fragment>
<iis:WebAppPool Id="MyAppPool" Name="My Web Console"/>
</Fragment>
然后我创建了以下自定义操作来处理应用程序池 create/remove:
<CustomAction Id="CreateIISAppPool"
Directory="TARGETDIR"
ExeCommand="[SystemFolder]inetsrv\appcmd add apppool /name:"My Web Console" /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"
Execute="deferred"
Return="ignore"
Impersonate="no" />
<CustomAction Id="DeleteIISAppPool"
Directory="TARGETDIR"
ExeCommand="[SystemFolder]inetsrv\appcmd delete apppool "My Web Console""
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 条件的升级中安装它。