Avoid unannounced system restart

When installing the .NET SDK or runtime, if the installer wants a system restart, it would do so quietly. This avoids the restart but adds a prompt at the end of the script to inform the user of a restart being required when necessary.

Fixes #57
This commit is contained in:
Andrew Arnott 2020-06-15 07:09:02 -06:00
Родитель 3c97ead14a
Коммит bc3f88d11b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: A9B9910CDCCDA441
2 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@ -44,6 +44,9 @@ $EnvVars = @{}
if (!$NoPrerequisites) {
& "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken -Force:$UpgradePrerequisites
& "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality
if ($LASTEXITCODE -eq 3010) {
Exit 3010
}
# The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests.
# But it only works on Windows.

Просмотреть файл

@ -77,8 +77,10 @@ Function Install-DotNet($Version, [switch]$Runtime) {
Write-Host "Downloading .NET Core $sdkSubstring$Version..."
$Installer = Get-InstallerExe -Version $Version -Runtime:$Runtime
Write-Host "Installing .NET Core $sdkSubstring$Version..."
cmd /c start /wait $Installer /install /quiet
if ($LASTEXITCODE -ne 0) {
cmd /c start /wait $Installer /install /passive /norestart
if ($LASTEXITCODE -eq 3010) {
Write-Verbose "Restart required"
} elseif ($LASTEXITCODE -ne 0) {
throw "Failure to install .NET Core SDK"
}
}
@ -95,16 +97,24 @@ if ($InstallLocality -eq 'machine') {
if ($IsMacOS -or $IsLinux) {
$DotNetInstallDir = '/usr/share/dotnet'
} else {
$restartRequired = $false
if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) {
Install-DotNet -Version $sdkVersion
$restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010)
}
$runtimeVersions | Get-Unique |% {
if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) {
Install-DotNet -Version $_ -Runtime
$restartRequired = $restartRequired -or ($LASTEXITCODE -eq 3010)
}
}
if ($restartRequired) {
Write-Host -ForegroundColor Yellow "System restart required"
Exit 3010
}
return
}
} elseif ($InstallLocality -eq 'repo') {