Skip to content

Commit a7eb192

Browse files
author
Christoph Bergmeister
committed
legacy/1.x: Backport PowerShell#909 and update .Net SDK version to be the same as in master
1 parent 74320f7 commit a7eb192

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

PowerShellEditorServices.build.ps1

+3-5
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-
$requiredSdkVersion = "2.0.0"
37+
$requiredSdkVersion = (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,10 +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 = (& $dotnetExePath --version) -replace '[+-].*$',''
58-
if ([version]$version -ge [version]$requiredSdkVersion) {
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) {
5957
$script:dotnetExe = $dotnetExePath
6058
}
6159
else {

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)