From 2d30ed32eac190b7c4eb9666507b0062d332d23e Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 9 Nov 2017 11:10:33 -0800 Subject: [PATCH] Don't use Mono MSBuild if it does not exist and display a helpful message for Linux users Fixes #1011 --- .../Discovery/Providers/MonoInstanceProvider.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/OmniSharp.Host/MSBuild/Discovery/Providers/MonoInstanceProvider.cs b/src/OmniSharp.Host/MSBuild/Discovery/Providers/MonoInstanceProvider.cs index 6247503056..2c25e6378d 100644 --- a/src/OmniSharp.Host/MSBuild/Discovery/Providers/MonoInstanceProvider.cs +++ b/src/OmniSharp.Host/MSBuild/Discovery/Providers/MonoInstanceProvider.cs @@ -82,6 +82,22 @@ public override ImmutableArray GetInstances() return NoInstances; } + // Look for Microsoft.Build.dll in the tools path. If it isn't there, this is likely a Mono layout on Linux + // where the 'msbuild' package has not been installed. + var microsoftBuildPath = Path.Combine(toolsPath, "Microsoft.Build.dll"); + if (!File.Exists(microsoftBuildPath)) + { + Logger.LogDebug($"Mono MSBuild could not be used because '{microsoftBuildPath}' does not exist."); + + if (Platform.Current.OperatingSystem == Utilities.OperatingSystem.Linux) + { + Logger.LogWarning(@"It looks like you have Mono 5.2.0 or greater installed but MSBuild could not be found. +Try installing MSBuild into Mono (e.g. 'sudo apt-get install msbuild') to enable better MSBuild support."); + } + + return NoInstances; + } + var propertyOverrides = ImmutableDictionary.CreateBuilder(StringComparer.OrdinalIgnoreCase); var localMSBuildPath = FindLocalMSBuildDirectory();