Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the way to look for the default MSBuild instance #1349

Merged
merged 10 commits into from
Jan 22, 2019
20 changes: 18 additions & 2 deletions src/OmniSharp.Host/MSBuild/Discovery/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using System.IO;
using Microsoft.Extensions.Logging;

namespace OmniSharp.MSBuild.Discovery
{
Expand All @@ -18,7 +19,9 @@ public static void RegisterDefaultInstance(this IMSBuildLocator msbuildLocator,
else
{
instanceToRegister = instance;
break;

if (instance.HasDotNetSdksResolvers())
johnnyasantoss marked this conversation as resolved.
Show resolved Hide resolved
break;
}
}

Expand All @@ -42,6 +45,19 @@ public static void RegisterDefaultInstance(this IMSBuildLocator msbuildLocator,
}


public static bool HasDotNetSdksResolvers(this MSBuildInstance instance)
{
const string dotnetSdkResolver = "Microsoft.DotNet.MSBuildSdkResolver";
return File.Exists(
Path.Combine(
instance.MSBuildPath,
"SdkResolvers",
dotnetSdkResolver,
dotnetSdkResolver + ".dll"
)
);
}

public static bool IsInvalidVisualStudio(this MSBuildInstance instance)
// MSBuild from Visual Studio 2017 RTM cannot be used.
=> instance.Version.Major == 15
Expand Down