Skip to content

Commit 80ed0f0

Browse files
Fix legacy CI (#1103)
* fix ci * use official url
1 parent 2ddcd13 commit 80ed0f0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Diff for: PowerShellEditorServices.build.ps1

+4-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if ($PSVersionTable.PSEdition -ne "Core") {
3434

3535
task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestPowerShellApi {
3636

37-
$minRequiredSdkVersion = "2.0.0"
37+
$minRequiredSdkVersion = (Get-Content (Join-Path $PSScriptRoot 'global.json') | ConvertFrom-Json).sdk.version
3838

3939
$dotnetPath = "$PSScriptRoot/.dotnet"
4040
$dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" }
@@ -52,13 +52,8 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestP
5252

5353
# Make sure the dotnet we found is the right version
5454
if ($dotnetExePath) {
55-
# dotnet --version can return a semver that System.Version can't handle
56-
# e.g.: 2.1.300-preview-01. The replace operator is used to remove any build suffix.
57-
$version = [version]((& $dotnetExePath --version) -replace '[+-].*$','')
58-
$maxRequiredSdkVersion = [version]::Parse("3.0.0")
59-
60-
# $minRequiredSdkVersion <= version < $maxRequiredSdkVersion
61-
if ($version -ge [version]$minRequiredSdkVersion -and $version -lt $maxRequiredSdkVersion) {
55+
# dotnet --version can write to stderr, which causes builds to abort, therefore use --list-sdks instead
56+
if ((& $dotnetExePath --list-sdks | ForEach-Object { $_.Split()[0] }) -contains $requiredSdkVersion) {
6257
$script:dotnetExe = $dotnetExePath
6358
}
6459
else {
@@ -80,7 +75,7 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestP
8075

8176
# Download the official installation script and run it
8277
$installScriptPath = "$([System.IO.Path]::GetTempPath())dotnet-install.$installScriptExt"
83-
Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/v2.0.0/scripts/obtain/dotnet-install.$installScriptExt" -OutFile $installScriptPath
78+
Invoke-WebRequest "https://dot.net/v1/dotnet-install.$installScriptExt" -OutFile $installScriptPath
8479
$env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet"
8580

8681
if (!$script:IsUnix) {

Diff for: global.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"version": "2.1.801"
4+
}
5+
}

0 commit comments

Comments
 (0)