diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index cc8e15f81..ea4d4362e 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -35,8 +35,15 @@ function Invoke-AppVeyorInstall { $dotNetCoreSDKVersion = $globalDotJson.sdk.version # don't try to run this script on linux - we have to do the negative check because IsLinux will be defined in core, but not windows if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion)) -and ! $IsLinux ) { - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # https://github.com/dotnet/announcements/issues/77 - Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 + try { + $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol + # To avoid SSL error, see https://github.com/dotnet/announcements/issues/77 and https://github.com/PowerShell/PowerShell/pull/6236/files + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 + } + finally { + [Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol + } .\dotnet-install.ps1 -Version $dotNetCoreSDKVersion Remove-Item .\dotnet-install.ps1 }