diff --git a/.appveyor.yml b/.appveyor.yml index 6c3ed31..757af25 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,4 +1,4 @@ -version: 0.2.50.{build} +version: 0.2.51.{build} image: Visual Studio 2017 build_script: - ps: >- diff --git a/CHANGELOG.md b/CHANGELOG.md index 752ebef..8051d77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## v0.2.51 + +* Use correct MSBuild SDK folder for .NET Core 3.0 and newer (tintoy/msbuild-project-tools-vscode#46). + ## v0.2.50 * Enable per-workspace override of `MSBuildExtensionsPath` and `MSBuildExtensionsPath32` (tintoy/msbuild-project-tools-vscode#35). diff --git a/src/LanguageServer.Common/Utilities/MSBuildHelper.cs b/src/LanguageServer.Common/Utilities/MSBuildHelper.cs index 912561e..e8b2a2b 100644 --- a/src/LanguageServer.Common/Utilities/MSBuildHelper.cs +++ b/src/LanguageServer.Common/Utilities/MSBuildHelper.cs @@ -1,6 +1,7 @@ using Microsoft.Build.Construction; using Microsoft.Build.Evaluation; using Microsoft.Build.Exceptions; +using NuGet.Versioning; using System; using System.Collections.Generic; using System.IO; @@ -82,10 +83,16 @@ public static ProjectCollection CreateProjectCollection(string solutionDirectory ProjectCollection projectCollection = new ProjectCollection(globalProperties) { IsBuildEnabled = false }; + SemanticVersion netcoreVersion; + if (!SemanticVersion.TryParse(runtimeInfo.Version, out netcoreVersion)) + throw new FormatException($"Cannot parse .NET Core version '{runtimeInfo.Version}' (does not appear to be a valid semantic version)."); + + // For .NET Core 3.0 and newer, toolset version is simply "Current" instead of "15.0" (tintoy/msbuild-project-tools-vscode#46). + string toolsVersion = netcoreVersion.Major < 3 ? "15.0" : "Current"; + // Override toolset paths (for some reason these point to the main directory where the dotnet executable lives). - Toolset toolset = projectCollection.GetToolset("15.0"); - toolset = new Toolset( - toolsVersion: "15.0", + Toolset toolset = projectCollection.GetToolset(toolsVersion); + toolset = new Toolset(toolsVersion, toolsPath: runtimeInfo.BaseDirectory, projectCollection: projectCollection, msbuildOverrideTasksPath: ""