From 3b4f5419eec1d7bc9c5a4d4f12e1cf7a05148e80 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Wed, 13 Nov 2019 09:46:16 -0800 Subject: [PATCH 1/2] fix ci --- PowerShellEditorServices.build.ps1 | 11 +++-------- global.json | 5 +++++ 2 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 global.json diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 0a59bad52..a9bf32fc1 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -34,7 +34,7 @@ if ($PSVersionTable.PSEdition -ne "Core") { task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestPowerShellApi { - $minRequiredSdkVersion = "2.0.0" + $minRequiredSdkVersion = (Get-Content (Join-Path $PSScriptRoot 'global.json') | ConvertFrom-Json).sdk.version $dotnetPath = "$PSScriptRoot/.dotnet" $dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" } @@ -52,13 +52,8 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestP # Make sure the dotnet we found is the right version if ($dotnetExePath) { - # dotnet --version can return a semver that System.Version can't handle - # e.g.: 2.1.300-preview-01. The replace operator is used to remove any build suffix. - $version = [version]((& $dotnetExePath --version) -replace '[+-].*$','') - $maxRequiredSdkVersion = [version]::Parse("3.0.0") - - # $minRequiredSdkVersion <= version < $maxRequiredSdkVersion - if ($version -ge [version]$minRequiredSdkVersion -and $version -lt $maxRequiredSdkVersion) { + # dotnet --version can write to stderr, which causes builds to abort, therefore use --list-sdks instead + if ((& $dotnetExePath --list-sdks | ForEach-Object { $_.Split()[0] }) -contains $requiredSdkVersion) { $script:dotnetExe = $dotnetExePath } else { diff --git a/global.json b/global.json new file mode 100644 index 000000000..0c8476678 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "2.1.801" + } +} From ff091bb2cac610562fde053238bb772e23b1e126 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Wed, 13 Nov 2019 09:54:01 -0800 Subject: [PATCH 2/2] use official url --- PowerShellEditorServices.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index a9bf32fc1..43fa11892 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -75,7 +75,7 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestP # Download the official installation script and run it $installScriptPath = "$([System.IO.Path]::GetTempPath())dotnet-install.$installScriptExt" - Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/v2.0.0/scripts/obtain/dotnet-install.$installScriptExt" -OutFile $installScriptPath + Invoke-WebRequest "https://dot.net/v1/dotnet-install.$installScriptExt" -OutFile $installScriptPath $env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" if (!$script:IsUnix) {