How to fix OmniSharp broken in dotnet 3.1 image
- VSCode Version: 1.67.2
- Local OS Version: macOS 12.4
- Local chip architecture: Apple Silicon
- Reproduces in: Codespaces
- Name of Dev Container Definition with Issue: dotnet
Steps to Reproduce:
- Create a codespace from https://github.com/microsoft/vscode-remote-try-dotnetcore
- Open
Program.csafter the C# extension is installed (the extension might require a reload to fully activate) - See this error in the output:
Starting OmniSharp server at 5/25/2022, 6:57:38 PM
Target: /workspaces/vscode-remote-try-dotnetcore
[ERROR] Error: Found dotnet version 3.1.419. Minimum required version is 6.0.100.
- 🐛 OmniSharp doesn't load, and IntelliSense is broken
Notes
This appears to be due to a breaking change in the latest OmniSharp release which will require compensating changes in either the image or the template: https://github.com/OmniSharp/omnisharp-vscode/issues/5120#issuecomment-1136335405
v1.25.0 has shipped with this change. A .NET 6 SDK is required when running with "omnisharp.useModernNet" set to "true", which is the default configuration.
Either we should include a newer .NET 6 SDK on all versions of the .NET devcontainer images in order to allow OmniSharp to work, or we should add a setting for .NET versions <6 to set "omnisharp.useModernNet": false to workaround.
Either we should include a newer .NET 6 SDK on all versions of the .NET devcontainer images in order to allow OmniSharp to work, or we should add a setting for .NET versions <6 to set "omnisharp.useModernNet": false to workaround.
Either makes sense to me. We'd probably want to update the images themselves longer-term (option 1), in case folks are accessing them directly beyond this template?
Any idea how I can fix temporarily meanwhile waiting for the fix it?
Root-cause:
After the release of OmniSharp v1.25.0, the extension no longer ships with an included Mono & MSBuild tools. This means you need the tools in your local machine to run the extension.
There are two fixes:
[Option 1] A workaround by downgrading the OmniSharp extension version, which I do not recommend!
[Option 2] Setup omnisharp.useModernNet setting to false and:
- In the case of Linux or MacOS systems operational, install Mono including MSBuild (Download).
- In the case of Windows systems operational, install Visual Studio MSBuild Tools or a full Visual Studio installed (Download).
I've tested both solutions and both worked. Again I highly recommend the second one.
Hello everyone. I fixed it, but it's temporary.
in the vscode setting I turn off useModernNet like @jkeech mentioned in the main comment and I need to download mono in my computer, and set MonoPath /Library/Frameworks/Mono.framework/Versions/Current/
@gcamou This indeed did it for me too! I'm so happy this thread has been created about this problem because I started having issues with this problem yesterday and could not explain why the f*** this happened now.... Thanks a lot guys!
@sergiocyklpoint tysm the second solution worked for me!
Same here.
Installing a previous extension version does not work either => "Not compatible with my current version of vscode". Gonna have to install mono :/ MONO? Looks like C# is a second class citizen in vscode :/
Managed to get it to work
I use devContainers and this is my dockerfile
ARG VARIANT="3.1"
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:${VARIANT}
RUN groupadd docker
RUN usermod -aG docker vscode
# This fixes dotnet test breaking tty
RUN touch ~/.bashrc
RUN echo ' \n\
dotnet () \n\
{ \n\
local RET_VAL; \n\
local BEFORE=$(stty -g); \n\
$(which dotnet) "$@"; \n\
RET_VAL=$?; \n\
sleep 0.33; \n\
stty "${BEFORE}"; \n\
return $RET_VAL \n\
} ' >> /home/vscode/.bashrc
# This fixes omnisharp
RUN apt-get install gnupg ca-certificates
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list
RUN apt-get update -y
RUN apt-get install mono-devel -y
Plus this setting: "omnisharp.useModernNet": false
Updated the title of this issue so that it's reflected as the issue users can review for workarounds if they encounter this. Please see the comments above (https://github.com/microsoft/vscode-dev-containers/issues/1474#issuecomment-1138768231) for how to address this.