简体   繁体   English

如何快速连续安装 IIS 服务器和主机包而不会出错?

[英]How to install IIS Server and Hosting bundle in quick succession without running into errors?

If I install the IIS Server and Hosting bundle in quick succession like this (on a new Windows 10 Server):如果我像这样快速连续安装 IIS 服务器和托管捆绑包(在新的 Windows 10 服务器上):

Install-WindowsFeature -Name Web-Server -IncludeAllSubFeature -IncludeManagementTools

# Ignore the next line for now, its my current workaround
Start-Sleep -Seconds 120

Write-Host "-- Installing Dotnet Hosting Bundle"
$ErrorActionPreference = "Stop";
$tempDir = [System.IO.Path]::GetTempPath()
$downloadPath = "$tempdir\netCoreHostingBundle.exe";
$DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy;

$securityProtocol = @();
$securityProtocol += [Net.ServicePointManager]::SecurityProtocol;
$securityProtocol += [Net.SecurityProtocolType]::Tls12;
[Net.ServicePointManager]::SecurityProtocol = $securityProtocol;
$WebClient = New-Object Net.WebClient; 

$Uri = 'https://download.visualstudio.microsoft.com/download/pr/0d000d1b-89a4-4593-9708-eb5177777c64/cfb3d74447ac78defb1b66fd9b3f38e0/dotnet-hosting-6.0.6-win.exe';
if ($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))) { $WebClient.Proxy = New-Object Net.WebProxy($DefaultProxy.GetProxy($Uri).OriginalString, $True); };
$WebClient.DownloadFile($Uri, $downloadPath);
 
$arguments = New-Object -TypeName System.Collections.Generic.List[System.String]
$arguments.Add("/quiet")
$arguments.Add("/norestart")
Start-Process -FilePath $downloadPath -ArgumentList $arguments -NoNewWindow -Wait -PassThru -WorkingDirectory $tempDir

Write-Host "-- Restarting IIS"
Stop-Service W3SVC
Start-Service W3SVC
Get-Service W3SVC

Everything works out fine from the installation point of view.从安装的角度来看,一切正常。 But if I run a NET Core Application in IIS the following error occurs:但是,如果我在 IIS 中运行 NET Core 应用程序,则会出现以下错误:

HTTP Error 500.19 - HRESULT code 0x8007000d HTTP 错误 500.19 - HRESULT 代码 0x8007000d

Googling around this happens when "Hosting Bundle is installed before IIS". 当“在 IIS 之前安装主机包”时,会发生谷歌搜索。 The simple solution is written in the next sentence: "the bundle installation must be repaired" and indeed this works. 简单的解决方案写在下一句中:“必须修复捆绑安装” ,这确实有效。

The Question being now:现在的问题是:

  • How do I avert the situation altogether?我如何完全避免这种情况?
  • or How do I wait till IIS is really installed, so it is safe to install the Hosting Bundle?或者我如何等到真正安装 IIS,所以安装 Hosting Bundle 是安全的?

If the Hosting Bundle is installed before IIS, the bundle installation must be repaired.如果在 IIS 之前安装了 Hosting Bundle,则必须修复捆绑安装。 Run the Hosting Bundle installer again after installing IIS.安装 IIS 后再次运行 Hosting Bundle 安装程序。

This is the method I found in another site:这是我在另一个网站上找到的方法:

Use a custom action that enables IIS before the installation of ".NET Core IIS Hosting" prerequisite.在安装“.NET Core IIS Hosting”先决条件之前,使用启用 IIS 的自定义操作。

For example, you can add a custom action as a non-sequential custom action (so it can be triggered from a UI control) and then schedule it in the "Dialogs" page --> "Pre-install UI" --> "WelcomePrereqDlg" dialog --> "Next" button.例如,您可以将自定义操作添加为非顺序自定义操作(因此可以从 UI 控件触发),然后将其安排在“对话框”页面-->“预安装 UI”-->“ WelcomePrereqDlg" 对话框 --> "Next" 按钮。 This will enable IIS before installing the prerequisites.这将在安装先决条件之前启用 IIS。

The method comes from this link: https://www.advancedinstaller.com/forums/viewtopic.php?t=44696方法来自这个链接: https://www.advancedinstaller.com/forums/viewtopic.php?t=44696

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM