vscode-csharp: OmniSharp stops working after Mono is installed.
Environment data
.NET Command Line Tools (2.1.3)
Product Information:
Version: 2.1.3
Commit SHA-1 hash: a0ca411ca5
Runtime Environment:
OS Name: gentoo
OS Version:
OS Platform: Linux
RID: linux-x64
Base Path: /opt/dotnet_core/sdk/2.1.3/
Microsoft .NET Core Shared Framework Host
Version : 2.0.4
Build : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff
VS Code version: 1.20.0-1516947444 C# Extension version: 1.13.1
Steps to reproduce
Install the .NET Core SDK without Mono and a fresh install of VSCode. Open up a C# project and verify that extension functionality works.
Install Mono alongside the dotnet tool. Try opening the same project in VSCode.
Install MSBuild for Mono since the OmniSharp warning suggests to do so. Try opening the same project in VSCode.
Expected behavior
Intellisense, CodeLens, etc. works in all three scenarios. After installing MSBuild, the warning that it is not installed goes away.
Actual behavior
Intellisense, CodeLens, etc. only work in the case where .NET Core is installed without Mono or Mono MSBuild. The warning that MSBuild is not installed remains after it is installed alongside Mono.
Starting OmniSharp server at 2/2/2018, 12:25:16 AM
Target: /home/jaccarmac/src/src/jaccarmac.com/junkcode/free-monad-vs-typeclass
OmniSharp server started wth Mono
Path: /home/jaccarmac/.vscode-insiders/extensions/ms-vscode.csharp-1.13.1/.omnisharp/omnisharp/OmniSharp.exe
PID: 20413
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on gentoo 0.0 (x64)
[warn]: OmniSharp.MSBuild.Discovery.Providers.MonoInstanceProvider
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.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 15.0 - "/home/jaccarmac/.vscode-insiders/extensions/ms-vscode.csharp-1.13.1/.omnisharp/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to '/home/jaccarmac/.vscode-insiders/extensions/ms-vscode.csharp-1.13.1/.omnisharp/omnisharp/msbuild/15.0/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 15.0 - "/home/jaccarmac/.vscode-insiders/extensions/ms-vscode.csharp-1.13.1/.omnisharp/omnisharp/msbuild/15.0/Bin"
MSBuildExtensionsPath = /usr/lib/mono/xbuild
CscToolPath = /home/jaccarmac/.vscode-insiders/extensions/ms-vscode.csharp-1.13.1/.omnisharp/omnisharp/msbuild/15.0/Bin/Roslyn
CscToolExe = csc.exe
MSBuildToolsPath = /home/jaccarmac/.vscode-insiders/extensions/ms-vscode.csharp-1.13.1/.omnisharp/omnisharp/msbuild/15.0/Bin
TargetFrameworkRootPath = /usr/lib/mono/xbuild-frameworks
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/home/jaccarmac/src/src/jaccarmac.com/junkcode/free-monad-vs-typeclass'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
Initializing in /home/jaccarmac/src/src/jaccarmac.com/junkcode/free-monad-vs-typeclass
[info]: OmniSharp.DotNet.DotNetProjectSystem
Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
Resolving projects references
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
No solution files found in '/home/jaccarmac/src/src/jaccarmac.com/junkcode/free-monad-vs-typeclass'
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
Loading project: /home/jaccarmac/src/src/jaccarmac.com/junkcode/free-monad-vs-typeclass/free-monad-vs-typeclass.csproj
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
Failed to load project file '/home/jaccarmac/src/src/jaccarmac.com/junkcode/free-monad-vs-typeclass/free-monad-vs-typeclass.csproj'.
/home/jaccarmac/src/src/jaccarmac.com/junkcode/free-monad-vs-typeclass/free-monad-vs-typeclass.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. /opt/dotnet_core/sdk/2.1.3/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00042] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.VerifyThrowInvalidProject[T1] (System.Boolean condition, System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00003] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpression (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.String unescapedExpression, System.Boolean throwOnFileNotExistsError, System.Collections.Generic.List`1[Microsoft.Build.Construction.ProjectRootElement]& imports) [0x00517] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpressionConditioned (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.Collections.Generic.List`1[Microsoft.Build.Construction.ProjectRootElement]& projects, System.Boolean throwOnFileNotExistsError) [0x001a6] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00024] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00000] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x001dd] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0002d] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000c8] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Framework.BuildEventContext buildEventContext) [0x000df] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData`4[P,I,M,D] data, Microsoft.Build.Construction.ProjectRootElement root, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, System.Int32 maxNodeCount, Microsoft.Build.Collections.PropertyDictionary`1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory`2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCache projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.Execution.ProjectInstance projectInstanceIfAnyForDebuggerOnly, Microsoft.Build.BackEnd.SdkResolution sdkResolution) [0x00016] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x0004c] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00034] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation) [0x00000] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary () [0x00007] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Project.Initialize (System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x000e9] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x0009c] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection) [0x00000] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f5] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <9ba305957e954df9b0ed46d97ba8f5be>:0
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.LoadProject (System.String filePath, System.String solutionDirectory, Microsoft.Extensions.Logging.ILogger logger, OmniSharp.MSBuild.Discovery.MSBuildInstance msbuildInstance, OmniSharp.MSBuild.SdksPathResolver sdksPathResolver, OmniSharp.Options.MSBuildOptions options, System.Collections.Generic.ICollection`1[T] diagnostics, System.Collections.Immutable.ImmutableArray`1[System.String]& targetFrameworks) [0x00054] in <e904597b17e840d49e5c532b51773be0>:0
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Create (System.String filePath, System.String solutionDirectory, Microsoft.Extensions.Logging.ILogger logger, OmniSharp.MSBuild.Discovery.MSBuildInstance msbuildInstance, OmniSharp.MSBuild.SdksPathResolver sdksPathResolver, OmniSharp.Options.MSBuildOptions options, System.Collections.Generic.ICollection`1[T] diagnostics) [0x0000a] in <e904597b17e840d49e5c532b51773be0>:0
at OmniSharp.MSBuild.MSBuildProjectSystem.LoadProject (System.String projectFilePath) [0x00038] in <e904597b17e840d49e5c532b51773be0>:0
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/home/jaccarmac/src/src/jaccarmac.com/junkcode/free-monad-vs-typeclass'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.Stdio.Host
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Stdio.Host
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/home/jaccarmac/src/src/jaccarmac.com/junkcode/free-monad-vs-typeclass' on host 18205.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 11
- Comments: 55 (14 by maintainers)
I’m on arch solved this issue by uninstall “msbuild-bin” and install “msbuild-stable” (15.4_xamarinxplat.2017.11.27.11.23_0xamarin1_ubuntu1404b1-3) instead.
Could you try setting “omnisharp.useGlobalMono”: never and then restarting the omnisharp server.
AAAARGH! Of course, I’m so sorry, I should have known better. Installed mono from the mono apt repo at https://www.mono-project.com/download/stable/ and all is good again!!
Thanks so much for your help, Filip!
After uninstalling
mono
on arch, you have to reinstall the 3dotnet
packages. (host, runtime, sdk)On fedora, after installing mono-complete (5.14.0.177) from the mono repo (mono-centos7-stable) I had this error. It was resolved after installing the msbuild package from the same repo (
sudo dnf install msbuild
)I think I’ve worked out what the problem is. Mono provide a package called msbuild, currently version 1:15.4+xamarinxplat.2017.11.27.11.23-0xamarin1+ubuntu1404b1. It isn’t a dependency of mono-devel, so it doesn’t get installed if you install mono in the recommended way. (It is a dependency of mono-complete.)
Installing this package prevents the error. At this point I’m speculating, but perhaps if Mono is installed, Omnisharp tries to use it, and then fails because msbuild is missing.
I’m running Ubuntu (16.04) so your fix may be slightly different if you’re on a different distro.
Also a word of explanation - the reason why latest Omnisharp suddenly requires Mono 6.4.0 is that this is the version of Mono that supports .NET Core 3.0 (or rather contains msbuild 16.3 that supports .NET Core 3.0). Unfortunately the rules of minimum Mono versions are not very well enforced in the code at the moment, so OmniSharp can still pick up an older one and that results in potential problems.
mono-complete is the superset of mono-devel so it’s fine. However OmniSharp now requires at least Mono 6.4.0 - it would be best to update the installation to that version (that’s actually the latest stable). The problem is that even if OmiSharp runs standalone mode and doesn’t use global mono, some of the msbuild extension paths and such will still be inherited from mono therefore if it’s an old version things might start breaking down.
Same here… Omnisharp seems to break for me every couple of months.
I’m on Solus, and after I installed the
mono-msbuild
package from my system package manager, I’m experiencing similar problems but with different errors. Installing that system package “permanently” broke Omnisharp. Permanently, meaning something got set that isn’t being unset when the package is removed.I believe it may be related so I didn’t want to start a new issue, but if I need to, let me know. I receive the error at the bottom of this comment.
Even after reverting my development system back to how it was initially, it’s still trying to load system mono instead of the one supplied by omnisharp. I did the following:
15.8
5.14.0.177
3.0.100-preview3-010431
I still receive the same error every time VSCode starts up. I can no longer have mono installed on my system at all.
Before installing mono-msbuild from my package manager, I was getting the error mentioned in #2876, so even though it was broken at that point, it was at least looking in the right place for mono. Now it isn’t.
If I completely remove my system
mono
package, I get back to where I was with issue #2876, even though the problem started when I installed systemmono-msbuild
, which is no longer installed.Hopefully my log will be of some help. If anyone has any ideas how I can get mono reinstalled without interfering with omnisharp, I’m all ears.