Open rshillington opened 6 years ago
@rshillington: Could you provide your full OmniSharp Log? Seeing the information at the top is helpful for seeing how OmniSharp was initialized.
Attached is I believe what you're looking for? Perhaps there's a way to get OmniSharp to be more verbose in its logging, which I'm happy to turn on.
Thanks! That was what indeed I was looking for. Seeing the top of the log where the information about how MSBuild is set up is very helpful.
I have a couple of potential options to try that might address the problem for you:
Try setting the "omnisharp.path"
VS Code setting to "latest"
. This will cause C# for VS Code to download and install the latest build of OmniSharp, which includes some recent fixes to the MSBuild project system. One of these fixes is around SDK resolution, which might positively impact your setup.
If that doesn't work, try downloading and installing the latest stable Mono MDK from http://www.mono-project.com/download/stable/. When C# for VS Code detects a valid version of Mono on the machine, it will launch OmniSharp on it. And, in that case, it will use the MSBuild bits that ship with Mono. Note: If you choose to install via Homebrew, use brew cask install mono-mdk
rather than brew install mono
. The latter does not include a recent enough version of Mono.
Please let me know if either of these solutions work for you.
Hi @DustinCampbell ,
I've had the same issue after trying your steps above. I just installed .NET Core on MacOS and tried to get the dotnet Angular project template working. My error message is
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/Users/tvc/dotnet-angular/dotnet-angular.csproj'.
/Users/tvc/dotnet-angular/dotnet-angular.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
(The file dotnet-angular.csproj begins with <Project Sdk="Microsoft.NET.Sdk.Web">
).
My dotnet --info
:
.NET Command Line Tools (2.1.200)
Product Information:
Version: 2.1.200
Commit SHA-1 hash: 2edba8d7f1
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/2.1.200/
Microsoft .NET Core Shared Framework Host
Version : 2.0.7
Build : 2d61d0b043915bc948ebf98836fefe9ba942be11
I am using VS Code Version 1.23.1.
I followed your advice and set "omnisharp.path"
to "latest"
and ran the command brew cask install mono-mdk
, but I'm still having the issue.
Here is the OmniSharp Log with loggingLevel
set to "trace"
: vscode_sdk_error_tracelog.txt
FYI the directory /Users/tvc/.vscode/extensions/ms-vscode.csharp-1.15.2/.omnisharp/1.30.1-beta.63/omnisharp/msbuild/15.0/Bin/Sdks
does not exist. Is it possible to override MSBuildSDKsPath
? I can't seem to change it via an environmental variable.
@tomvonclef : The log that you provided leads me to believe that that something is different about your machine configuration because it didn't even detect that Mono had been installed. When you run mono --version
in a terminal window, do you get any output? Have you set your Path
environment variable differently in some way?
@DustinCampbell mono --version
outputs:
Mono JIT compiler version 5.12.0.226 (2018-02/9824e260f56 Mon Apr 30 18:45:52 EDT 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(3.6.0svn-mono-master/8b1520c8aae)
GC: sgen (concurrent by default)
mono
is /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono
My PATH
is: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands
Is there an issue with just using ~/.vscode/extensions/ms-vscode.csharp-1.15.2/.omnisharp/1.30.1-beta.63/bin/mono.osx
?
Also, I'm not sure my situation is different from @rshillington. The log lines below show up for me because my logging level includes debug messages. I don't understand why a failure to locate Mono is a debug message that never shows up in the VS Code UI.
[dbug]: OmniSharp.MSBuild.Discovery.Providers.MonoInstanceProvider
Could not retrieve Mono runtime path
Yes, I agree that the behavior seems similar between the both you and @rshillington. Do you also see different behavior depending on if you launch VS Code by typing code .
at a terminal window vs. launch VS Code from the OSX launch bar? Are you able to launch dotnet --info
and mono --version
from within VS Code's integrated terminal?
OK, things work if I launch via typing code .
in the terminal!
FYI, things are still broken if I launch from the dock. dotnet --info
and mono --version
return the same correct results from VS Code's integrated terminal whether I launch from the dock or the terminal.
Here is the log created when I launch from the terminal and things work: omnisharp-vscode-tracelog-started-from-terminal.txt
Launching with code .
causes the version of Mono installed with brew
to be discovered:
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Mono 15.0 - "/Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin"
2: StandAlone 15.0 - "/Users/tvc/.vscode/extensions/ms-vscode.csharp-1.15.2/.omnisharp/1.30.1-beta.63/omnisharp/msbuild/15.0/Bin"
Also, MSBuildSDKsPath
gets set to
/Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Sdks
, which contains the correct files. When I launch from the Dock MSBuildSDKsPath
is set to /Users/tvc/.vscode/extensions/ms-vscode.csharp-1.15.2/.omnisharp/1.30.1-beta.63/omnisharp/msbuild/15.0/Bin/Sdks
, which does not exist.
This is progress! :smile:
I have a suspicion that your PATH is different somehow when launching VS Code from the macOS LaunchPad, though I don't know why that would be. I'm basing this on a couple of insights from the logs provide by yourself and @rshillington.
mono --version
to check the version of Mono that's installed. Then, if it finds a valid version, it launches OmniSharp on that Mono. So, if the log shows that it isn't launching on the installed Mono, that's an indicator that it didn't find it.dotnet
on the PATH. And, the MSBuild project errors that you're getting would indicate that it isn't finding dotnet
.Searching around on the Internet, I've found a number of issues where users have had troubles with the environment variables being different when launching an application via LaunchPad. I don't know why it would be that way on your machine, but I hope that gives you a lead to look into.
I ran into this after I installed something via Homebrew which also installed Mono 5.12.x
I found that rolling back to Mono 5.4.x solved the issue for now.
Not needed to rollback.. Just:
/etc/profile.d/dotnet.csh
setenv DOTNET_ROOT="/opt/dotnet"
setenv MSBuildSDKsPath="${DOTNET_ROOT}/sdk/$(${DOTNET_ROOT}/dotnet --version)/Sdks"
setenv PATH="${PATH}:${DOTNET_ROOT}"
/etc/profile.d/dotnet.sh
export DOTNET_ROOT=/opt/dotnet
export MSBuildSDKsPath=$DOTNET_ROOT/sdk/$(${DOTNET_ROOT}/dotnet --version)/Sdks
export PATH=${PATH}:${DOTNET_ROOT}
The MSBuildSDKsPath
env is required to get this ... working again -.-
For fish:
export DOTNET_ROOT="/opt/dotnet"
export MSBuildSDKsPath="$DOTNET_ROOT/sdk/"(eval $DOTNET_ROOT/dotnet --version)"/Sdks"
Not needed to rollback.. Just:
/etc/profile.d/dotnet.csh
setenv DOTNET_ROOT="/opt/dotnet" setenv MSBuildSDKsPath="${DOTNET_ROOT}/sdk/$(${DOTNET_ROOT}/dotnet --version)/Sdks" setenv PATH="${PATH}:${DOTNET_ROOT}"
/etc/profile.d/dotnet.sh
export DOTNET_ROOT=/opt/dotnet export MSBuildSDKsPath=$DOTNET_ROOT/sdk/$(${DOTNET_ROOT}/dotnet --version)/Sdks export PATH=${PATH}:${DOTNET_ROOT}
The
MSBuildSDKsPath
env is required to get this ... working again -.-
I don't have a path /etc/profile.d
. My issue is actually the opposite: works from launch pad, doesnt work from shell code .
. What sets up /etc/profile.d? My dotnet
runs from /usr/local/share/dotnet/dotnet
@davidfowl Which OS you use?
Environment data
VS Code version: 1.23.1
C# Extension version: 1.15.2
Steps to reproduce
Open a folder with a valid .csproj file and source code
Expected behavior
OmniSharp.MSBuild.ProjectManager should load without problem.
I tend to open VS Code a number of different ways, but the method that seems to produce this error is from terminal
code .
Actual behavior