Skip to content

Commit

Permalink
Use correct MSBuild SDK folder for .NET Core 3.0 and newer.
Browse files Browse the repository at this point in the history
  • Loading branch information
tintoy committed Dec 6, 2018
1 parent 644411c commit 7e01bb7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 0.2.50.{build}
version: 0.2.51.{build}
image: Visual Studio 2017
build_script:
- ps: >-
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
13 changes: 10 additions & 3 deletions src/LanguageServer.Common/Utilities/MSBuildHelper.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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: ""
Expand Down

0 comments on commit 7e01bb7

Please sign in to comment.