Imported Upstream version 3.8.0
[platform/upstream/protobuf.git] / csharp / install_dotnet_sdk.ps1
1 #!/usr/bin/env powershell
2 # Install dotnet SDK based on the SDK version from global.json
3
4 Set-StrictMode -Version 2
5 $ErrorActionPreference = 'Stop'
6
7 # avoid "Unknown error on a send" in Invoke-WebRequest
8 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
9
10 $InstallScriptUrl = 'https://dot.net/v1/dotnet-install.ps1'
11 $InstallScriptPath = Join-Path  "$env:TEMP" 'dotnet-install.ps1'
12 $GlobalJsonPath = Join-Path $PSScriptRoot '..' | Join-Path -ChildPath 'global.json'
13
14 # Resolve SDK version from global.json file
15 $GlobalJson = Get-Content -Raw $GlobalJsonPath | ConvertFrom-Json
16 $SDKVersion = $GlobalJson.sdk.version
17
18 # Download install script
19 Write-Host "Downloading install script: $InstallScriptUrl => $InstallScriptPath"
20 Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath
21 &$InstallScriptPath -Version $SDKVersion