Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

How to fix OmniSharp broken in dotnet 3.1 image #1474

Open
jkeech opened this issue May 25, 2022 · 8 comments
Open

How to fix OmniSharp broken in dotnet 3.1 image #1474

jkeech opened this issue May 25, 2022 · 8 comments
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@jkeech
Copy link
Member

jkeech commented May 25, 2022

  • 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:

  1. Create a codespace from https://github.com/microsoft/vscode-remote-try-dotnetcore
  2. Open Program.cs after the C# extension is installed (the extension might require a reload to fully activate)
  3. 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.
  1. 🐛 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: dotnet/vscode-csharp#5120 (comment)

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.

@bamurtaugh
Copy link
Member

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?

@gcamou
Copy link

gcamou commented May 26, 2022

Any idea how I can fix temporarily meanwhile waiting for the fix it?

@sergiocyklpoint
Copy link

sergiocyklpoint commented May 26, 2022

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.

@gcamou
Copy link

gcamou commented May 26, 2022

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/

@CTNOriginals
Copy link

@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!

@VoItaik
Copy link

VoItaik commented May 29, 2022

@sergiocyklpoint tysm the second solution worked for me!

@andreujuanc
Copy link

andreujuanc commented May 30, 2022

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

@joshspicer joshspicer added the bug Issue identified by VS Code Team member as probable bug label Jun 1, 2022
@bamurtaugh bamurtaugh changed the title OmniSharp broken in dotnet 3.1 image How to fix OmniSharp broken in dotnet 3.1 image Jun 13, 2022
@bamurtaugh
Copy link
Member

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 (#1474 (comment)) for how to address this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

8 participants