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 7 trap { 8 $ErrorActionPreference = "Continue" 9 Write-Error $_ 10 exit 1 11 } 12 13 # avoid "Unknown error on a send" in Invoke-WebRequest 14 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 15 16 $InstallScriptUrl = 'https://dot.net/v1/dotnet-install.ps1' 17 $InstallScriptPath = Join-Path "$env:TEMP" 'dotnet-install.ps1' 18 19 # Download install script 20 Write-Host "Downloading install script: $InstallScriptUrl => $InstallScriptPath" 21 Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath 22 &$InstallScriptPath -Version 2.1.504 23