install_dotnet_sdk.ps1 701 B

12345678910111213141516171819202122
  1. #!/usr/bin/env powershell
  2. # Install dotnet SDK needed to build C# projects on Windows
  3. Set-StrictMode -Version 2
  4. $ErrorActionPreference = 'Stop'
  5. trap {
  6. $ErrorActionPreference = "Continue"
  7. Write-Error $_
  8. exit 1
  9. }
  10. # avoid "Unknown error on a send" in Invoke-WebRequest
  11. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  12. $InstallScriptUrl = 'https://dot.net/v1/dotnet-install.ps1'
  13. $InstallScriptPath = Join-Path "$env:TEMP" 'dotnet-install.ps1'
  14. # Download install script
  15. Write-Host "Downloading install script: $InstallScriptUrl => $InstallScriptPath"
  16. Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath
  17. &$InstallScriptPath -Version 2.1.504