omnisharp-roslyn: MSBuild can not be found on Arch Linux
Since yesterday I keep getting this error when omnisharp starts up in vscode (omnisharp is set to latest version):
[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.
This used to work without issues before. I noticed that msbuild version was increased in a recent commit. Maybe that causes omnisharp to no longer find my msbuild on linux?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 43 (6 by maintainers)
Since you are on Arch, it’s no surprise that MSBuild cannot find your .NET Core SDK: not only it’s installed in non-standard location, but also
/usr/bin/dotnetis not a symlink andDOTNET_ROOTis not globally exported. Try the following (multiple at the same time if necessary):/usr/bin/dotnetwith a symlink to/opt/dotnet/dotnet/etc/profile.d, e.g.dotnet.sh, with the following content:export DOTNET_ROOT=/opt/dotnet(you might need to adapt this for some login shells, and make sure you relog afterwards)UseLegacySdkResolvertotruein youromnisharp.jsonYou could instead try exporting
MSBuildSdksPath, but it’s very prone to breakage and prevents you from using multiple SDK versions.See here for some details on what I found about .NET Core packages in Arch.
I removed
/usr/bin/dotnetand replaced it with/opt/dotnet/dotnetNothing else 😃
Install
msbuild-16-binfrom AUR and latestmonofrom official repository as suggested here works for me.I can confirm that @Saancreed’s solution also worked for me without installing
monoandmsbuild-bin-16.@masaeedu I vaguely recall seeing some piece of code that attempts to find first
dotnetin$PATHand resolve it withrealpath, but now that I tried to locate it again, I actually couldn’t. So I might have been mistaken here, or something was changed in 3.1 and it’s just no longer there. Anyway, source is available here, just in case you want to take a look.This also helped me.
This worked for me as well.
/usr/bin/dotnetis a shell script that execs/opt/dotnet/dotnetomnisharp-roslynand if it works without any other changes, then bisect can get us more info.You could also try getting
msbuildandmsbuild-sdkresolverfrom AUR, as your error log suggests that OmniSharp attempts to load extensions from legacyxbuildinstead.That said. what I can assure you is that it can work, but in my case it’s probably because I build my own
mono,msbuildandomnisharppackages from source: https://pastebin.com/PZiJ8bBQ (although it’s not very relevant here).