我有一个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>
然后我创建了以下自定义操作来处理应用程序池的创建/删除:
<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条件的升级中进行安装。