Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get OmniSharp VSCode intellisense to work with WSL-compiled code?

When I run dotnet build on my code from my WSL (Windows Subsystem for Linux) distro, C# intellisense breaks and I get errors like the following:

enter image description here

I've managed to set up the launch configurations found here, but that doesn't help with Intellisense, unless I've missed something.

I presume it has something to do with path configurations, but I'm not sure what to change, or where I should change it.

In short, how can I compile and run my code on WSL and edit it in VS Code without errors or warnings?

like image 676
Chris Paton Avatar asked Nov 01 '17 13:11

Chris Paton


People also ask

How do I fix VS Code IntelliSense not working?

Troubleshooting# If you find IntelliSense has stopped working, the language service may not be running. Try restarting VS Code and this should solve the issue. If you are still missing IntelliSense features after installing a language extension, open an issue in the repository of the language extension.

How do I run OmniSharp?

Click f1 key or ctrl+shift+p to open the textbox to enter your command. Then type omnisharp server, and select the option 'Restart omnisharp server'. You can look at its status in the bottom left corner of the window, and if you click on it, the process's status will on be displayed on the terminal.


2 Answers

As I fell into this question when I looked for this problem I decided to go back to show how I managed to solve it.

To OmniSharp work with WSL i installed the Insiders version of VS Code and the extension Remote - WSL. Done.

Links:

  • https://code.visualstudio.com/insiders/
  • https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl

OBS: You have to install on your WSL Linux distro the wget and msbuild

like image 127
Robert Gebhardt Avatar answered Oct 26 '22 08:10

Robert Gebhardt


There are more possible solutions:


Your folder structure is not correct:

  1. Use Terminal in VSCode and create a folder, like mkdir MyProject
  2. Create your project in the new folder from Terminal, for example: dotnet new console

Wrong Settings:

Go to:

Code -> Preferences -> Settings 

and remove "omnisharp.useMono": true/false

Additionally, you can open your project with Visual Studio or MonoDevelop and then reopen in VSCode.


You have wrong input parameters in your TryParseExact #LAUGHING

like image 20
Sean Stayns Avatar answered Oct 26 '22 07:10

Sean Stayns