Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omnisharp doesn't find System on Dotnet SDK >= 3.0 #3917

Closed
ishc3ice opened this issue Jul 19, 2020 · 13 comments
Closed

Omnisharp doesn't find System on Dotnet SDK >= 3.0 #3917

ishc3ice opened this issue Jul 19, 2020 · 13 comments

Comments

@ishc3ice
Copy link

ishc3ice commented Jul 19, 2020

Issue Description

When I open a Project with OmniSharp and the target Framework is set to 2.1, it works perfectly, but if i go higher than that (>= 3.0), it just says "The type or namespace name 'System' could not be found". It works perfectly when I press F5, or do dotnet run

Steps to Reproduce

Create any .NET Core >= 3.0 project and try to use Omnisharp

Expected Behavior

It should work on any .NET Core version

Actual Behavior

It doesn't and can't find any .NET Core classes

Logs

OmniSharp log

Post the output from Output-->Starting OmniSharp server at 7/19/2020, 8:38:47 PM Target: /home/noah/soda-lake-s-share/code/c#/hi ``` OmniSharp server started with Mono 6.10.0. Path: /home/noah/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/omnisharp/OmniSharp.exe PID: 119169

Starting OmniSharp on arch 0.0 (x64)
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Mono 16.4 - "/usr/lib/mono/msbuild/Current/bin"
2: StandAlone 16.4 - "/home/noah/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/omnisharp/.msbuild/Current/Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Mono 16.4 - "/usr/lib/mono/msbuild/Current/bin"
CscToolExe = csc.exe
CscToolPath = /home/noah/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/omnisharp/.msbuild/Current/Bin/Roslyn
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/home/noah/soda-lake-s-share/code/c#/hi'.
info: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
info: OmniSharp.MSBuild.ProjectSystem
No solution files found in '/home/noah/soda-lake-s-share/code/c#/hi'
info: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/home/noah/soda-lake-s-share/code/c#/hi'.
info: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
info: OmniSharp.MSBuild.ProjectManager
Loading project: /home/noah/soda-lake-s-share/code/c#/hi/hi.csproj
info: OmniSharp.WorkspaceInitializer
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/home/noah/soda-lake-s-share/code/c#/hi' on host 119063.
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Adding project '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'
info: OmniSharp.MSBuild.ProjectManager
Update project: hi
info: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'
info: OmniSharp.MSBuild.ProjectManager
Loading project: /home/noah/soda-lake-s-share/code/c#/hi/hi.csproj
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Update project: hi
[warn]: OmniSharp.MSBuild.PackageDependencyChecker
hi: Did not find 'Microsoft.NETCore.App' in lock file.
info: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'
info: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'
info: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'
info: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'
info: OmniSharp.MSBuild.ProjectManager
Loading project: /home/noah/soda-lake-s-share/code/c#/hi/hi.csproj
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Update project: hi
info: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'
info: OmniSharp.MSBuild.ProjectManager
Loading project: /home/noah/soda-lake-s-share/code/c#/hi/hi.csproj
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/home/noah/soda-lake-s-share/code/c#/hi/hi.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Update project: hi
info: OmniSharp.Roslyn.CSharp.Services.Diagnostics.ReAnalyzeService
Queue analysis for all projects.


### C# log ###
<details>Post the output from Output-->-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.3/System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/noah/soda-lake-s-share/code/c#/hi/bin/Debug/netcoreapp3.1/hi.dll'. Symbols loaded.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.3/System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.3/System.Console.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.3/System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.3/System.Runtime.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
</details>

## Environment information ##

**VSCode version**: 1.47.2
**C# Extension**: 1.22.1

<details><summary>Mono Information</summary>
        OmniSharp using global mono :6.10.0</details>
<details><summary>Dotnet Information</summary>
.NET Core SDK (reflecting any global.json):
 Version:   3.1.103
 Commit:    6f74c4a1dd

Runtime Environment:
 OS Name:     arch
 OS Version:  
 OS Platform: Linux
 RID:         arch-x64
 Base Path:   /usr/share/dotnet/sdk/3.1.103/

Host (useful for support):
  Version: 3.1.3
  Commit:  ed88943d24

.NET Core SDKs installed:
  2.1.808 [/usr/share/dotnet/sdk]
  3.1.103 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.NETCore.App 2.1.20 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
</details>
<details><summary>Visual Studio Code Extensions</summary>

|Extension|Author|Version|
|---|---|---|
|csharp|ms-dotnettools|1.22.1|;

</details>
@filipw
Copy link
Contributor

filipw commented Jul 19, 2020

looks like you have an outdated installation of global Mono. please update to at least 6.4 (ideally 6.10)

@ishc3ice
Copy link
Author

looks like you have an outdated installation of global Mono. please update to at least 6.4 (ideally 6.10)

I already have Mono 6.10

OmniSharp using global mono :6.10.0

@filipw
Copy link
Contributor

filipw commented Jul 23, 2020

yes but it must be missing the necessary msbuild (16.3+)

@ishc3ice
Copy link
Author

ishc3ice commented Jul 23, 2020

~ $ pacman -Q | grep msbuild
mono-msbuild 16.6.xamarinxplat.2020.04.29.14.43-1

@filipw
Copy link
Contributor

filipw commented Jul 23, 2020

I am not very familiar with Arch but we have only partial support for ot though see https://github.com/OmniSharp/omnisharp-roslyn#introduction

what your log shows is that the global mono you have doesn't have correct new msbuild bundled, hence the problem

what you need is the equivalent of mono-devel for Ubuntu

@JoeRobich
Copy link
Member

JoeRobich commented Jul 23, 2020

I believe that Arch has a msbuild-stable package that is known to work. See this comment #3769 (comment)

@filipw
Copy link
Contributor

filipw commented Jul 23, 2020

ah thanks @JoeRobich I couldn't find that.
I updated the instructions here OmniSharp/omnisharp-roslyn#1859

@ishc3ice
Copy link
Author

ishc3ice commented Jul 23, 2020

I replaced mono-msbuild with msbuild-stable, and it hasn't changed anything

@fosspill
Copy link

fosspill commented Jul 29, 2020

I can confirm that I'm experiencing this too. msbuild-stable sadly doesn't seem to resolve anything.

This issue also persists on the flatpak version, which can make sense since it seems to be referencing local packages as well.

Pressing F5 seems to be a decent workaround for now as it seems to help highlight actual issues in the code :)

@robertwahler
Copy link

I have this issue on macOS. Using stable mono 6.10, tried 6.12 too, but no go. I can only get OmniSharp 1.23.4 to provide partial IntelliSense for dotnet core projects. It can't handle any references to System.Threading.* using the global mono but it does work if I change to "omnisharp.useGlobalMono": "never".

I'd leave it at that but I can't use the never setting as it is only allowed in user and not workspace. I also use Unity and that requires real mono, the internal Omnisharp version will not function.

Basically, in order to keep working, I can only have one project open at a time and I have to swap the omnisharp.useGlobalMono setting to and from always and never before changing projects. I wish I understood the real issue so I could address it.

@filipw
Copy link
Contributor

filipw commented Oct 29, 2020

the problem is the incompatibility between the lowest MSBuild version required by the new .NET Core SDKs (16.7+) and the version available in any publicly available Mono (16.6)

the bundled Mono of Omnisharp is something we build ourselves so it has 16.8 and hence it works with latest.NET Core including .NET 5.0

you can find more info here #4007 (comment) and here mono/mono#20250

@robertwahler
Copy link

Thanks so much @filipw! I was able to configure an environment that works for Unity and DotNet Core at the same time with your information.

Here is what I had to do to work in VSCode in both Unity and DotNet core without changing the Omnisharp.useGlobalMono setting several times a day. The following setup also allows me to have Unity and DotNet Core projects open at the same time.

  • Downgrade all dotnet core projects to 3.0 (minor pain)
  • Set "Omnisharp.useGlobalMono": "always" in my VSCode user settings (can't use workspace)
  • Downgrade OmniSharp to version 1.22.0, later versions work in DotNet but not in Unity, I get tons of errors for dlls that can't be found

@JoeRobich
Copy link
Member

Closing as the modern .NET builds of O# should be used instead of the .NET Framework when loading SDK projects.

@JoeRobich JoeRobich closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants