Open Meligy opened 1 year ago
After some more investigation, I think I found the root issue, which is way less likely to happen than I originally thought...
Essentially, the answer lies in the Dotnet Information:
.NET SDKs installed:
6.0.202 [/usr/local/share/dotnet/sdk]
7.0.200 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
I was about confused because the Omnisharp log always says it's running as .NET 7, so I thought this was the problem.
But the actual problem seems to be that, given a .NET SDK 6.0.202 SDK installed and set in global.json, and the ability to go to the latest installed .NET 6 SDK allowed in the file, I also somehow had a .NET 6.0.4 runtime, but no .NET 6.0.4 SDK.
This is probably what confused Omnisharp. I think it looked for the missing .NET 6.0.4 SDK when it found the .NET 6.0.4 runtime. Because installing the .NET 6.0.4 SDK worked around the issue.
The correct behaviour would be to search only SDKs regardless of runtime. Or at least give a clear error about not finding the .NET 6.0.4 SDK specifically, or log the version in standard logging even.
But again, knowing that, it's a way less priority issue than originally thought.
Because installing the .NET 6.0.4 SDK worked around the issue.
I still don't understand the problem or solution. SDK 6.0.202 provides the runtime 6.0.4, which you already have. Are you saying omnisharp found runtime 6.0.13 and couldn't find some assets from the corresponding SDK 6.0.405?
I just installed the latest SDK 6.0.412 with runtime 6.0.20, but still get spurious omnisharp errors. I had to specify omnisharp.sdkVersion: 6.0.412
to get it working correctly.
global.json
{
"sdk": {
"version": "6.0.412",
"allowPrerelease": false,
"rollForward": "latestMinor"
}
}
omnisharp log
OmniSharp server started with .NET 7.0.203
.
Path: /Users/jam/.vscode/extensions/ms-dotnettools.csharp-1.26.0-darwin-x64/.omnisharp/1.39.7-net6.0/OmniSharp.dll
PID: 35910
Starting OmniSharp on Unknown 0.0 (Unknown)
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
Using the 'dotnet' on the PATH.
DotNetPath set to dotnet
Located 7 MSBuild instance(s)
1: .NET Core SDK 7.0.203 17.5.1 - "/usr/local/share/dotnet/sdk/7.0.203/"
2: .NET Core SDK 7.0.100 17.4.0 - "/usr/local/share/dotnet/sdk/7.0.100/"
3: .NET Core SDK 6.0.412 17.3.2 - "/usr/local/share/dotnet/sdk/6.0.412/"
4: .NET Core SDK 6.0.403 17.3.2 - "/usr/local/share/dotnet/sdk/6.0.403/"
5: .NET Core SDK 6.0.400 17.3.0 - "/usr/local/share/dotnet/sdk/6.0.400/"
6: .NET Core SDK 6.0.201 17.1.0 - "/usr/local/share/dotnet/sdk/6.0.201/"
7: .NET Core SDK 6.0.101 17.0.0 - "/usr/local/share/dotnet/sdk/6.0.101/"
Registered MSBuild instance: .NET Core SDK 7.0.203 17.5.1 - "/usr/local/share/dotnet/sdk/7.0.203/"
Issue Description
In
"omnisharp.useModernNet": true
mode, when you have a global.json file which restricts the major version of dotnet, for example"version": "6.0.202", "rollForward": "latestMinor"
, it ignores it, tries to use a higher dotnet version, which of course fails, causing a lot of fake errors like:Even though dotnet compilation fails, and setting the dotnet version manually in workspace settings works
Which is not a good worksaround, because it's a duplicate of the global.json file, and more importantly, because it does not allow a version range. I cannot say
6.0.*
for example, which is what to be expected when the global.json file has"rollForward": "latestMinor"
.Notes:
"omnisharp.path": "latest"
or settingomnisharp.path
at all.Steps to Reproduce
dotnet --list-sdks
Expected Behavior
Omnisharp to pick up the global.json file, and use the highest compatible .NET SDK version
Actual Behavior
Omnisharp Output says it's using the highest SDK (7 in the steps) and logs below show it doesn't see the
global.json
file.This happens even if there's another similar file in a higher folder or user level.
Also worth noting that in the logs it says it didn't see a global.json file, although it exists and it's applicable as confirmed by dotnet CLI commands.
Logs
OmniSharp log
C# log
Environment information
VSCode version: 1.76.0-insider C# Extension: 1.25.4
Mono Information
OmniSharp using mono: 6.12.0Dotnet Information
.NET SDK: Version: 7.0.200 Commit: 534117727b Runtime Environment: OS Name: Mac OS X OS Version: 13.2 OS Platform: Darwin RID: osx.13-arm64 Base Path: /usr/local/share/dotnet/sdk/7.0.200/ Host: Version: 7.0.3 Architecture: arm64 Commit: 0a2bda10e8 .NET SDKs installed: 6.0.202 [/usr/local/share/dotnet/sdk] 7.0.200 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Other architectures found: None Environment variables: DOTNET_ROOT [/usr/local/share/dotnet] global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/downloadVisual Studio Code Extensions
|Extension|Author|Version| |---|---|---| |classynaming|reflectiondm|1.2.0| |Code-Like-A-Rainbow|Invillia|0.3.0| |copilot-labs|GitHub|0.10.726| |copilot-nightly|GitHub|1.74.8965| |csharp|ms-dotnettools|1.25.4| |dotnet-test-explorer|formulahendry|0.7.8| |jupyter|ms-toolsai|2023.2.1000552237| |jupyter-keymap|ms-toolsai|1.0.0| |jupyter-renderers|ms-toolsai|1.0.15| |markdown-pdf|yzane|1.4.4| |msbuild-project-tools|tintoy|0.4.9| |prettier-vscode|esbenp|9.10.4| |roslynator|josefpihrt-vscode|4.2.0| |semantic-darcula|JuanMiret|0.0.2| |semantic-rainbow|thertzlor|1.1.5| |shell-syntax|bmalehorn|1.0.5| |Theme-rainbow|gerane|0.0.5| |vscode-drawio|hediet|1.6.6| |vscode-eslint|dbaeumer|2.4.0| |vscode-javascript-booster|sburg|14.0.1| |vscode-jupyter-cell-tags|ms-toolsai|0.1.6| |vscode-jupyter-slideshow|ms-toolsai|0.1.5| |vscode-styled-components|styled-components|1.7.6| |vscode-versionlens|pflannery|1.5.0|;