1 #!/usr/bin/env powershell 2 # Install dotnet SDK needed to build C# projects on Windows 3 4 Set-StrictMode -Version 2 5 $ErrorActionPreference = 'Stop' 6 # Disable progress bar to avoid getting the 7 # '"Access is denied" 0x5 occurred while reading the console output buffer' 8 # error when running on kokoro (i.e. in non-interactive mode) 9 $global:ProgressPreference = 'SilentlyContinue' 10 11 trap { 12 $ErrorActionPreference = "Continue" 13 Write-Error $_ 14 exit 1 15 } 16 17 # avoid "Unknown error on a send" in Invoke-WebRequest 18 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 19 20 $InstallScriptUrl = 'https://dot.net/v1/dotnet-install.ps1' 21 $InstallScriptPath = Join-Path "$env:TEMP" 'dotnet-install.ps1' 22 23 # Download install script 24 Write-Host "Downloading install script: $InstallScriptUrl => $InstallScriptPath" 25 Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath 26 27 # Installed versions should be kept in sync with 28 # templates/tools/dockerfile/csharp_dotnetcli_deps.include 29 &$InstallScriptPath -Version 3.1.415 30 &$InstallScriptPath -Version 6.0.100 31