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

Using .NET SDK 6 RC2 and getting 'Predefined type 'System....' is not defined or imported (csharp CS0518) #2247

Open
schaveyt opened this issue Oct 16, 2021 · 3 comments

Comments

@schaveyt
Copy link

Issue Description

Using .NET SDK 6 RC2 and getting 'Predefined type 'System....' is not defined or imported (csharp CS0518)

Steps to Reproduce

  1. Install .NET SDK 6 RC2
  2. Install C# extension 1.23.16
  3. Create a new ASP.NET project
cd \temp
dotnet new blazorserver -o test_app
code test_app
  1. Open the Program.cs file

Expected Behavior

The Program.cs file should have no squiggles or reported issues.

Actual Behavior

Various lines of code are reporting squiggles for the error:
'Predefined type 'System....' is not defined or imported (csharp CS0518)

image

Logs

OmniSharp log

Starting OmniSharp server at 10/16/2021, 5:52:36 PM Target: c:\temp\test-app

OmniSharp server started.
Path: c:\Users\210053326.vscode\extensions\ms-dotnettools.csharp-1.23.16.omnisharp\1.37.16\OmniSharp.exe
PID: 18732

Starting OmniSharp on Windows 6.2.9200.0 (x64)
info: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
info: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 4 MSBuild instance(s)
1: Visual Studio Professional 2017 15.9.28307.1000 15.9.21 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin"
2: Visual Studio Community 2019 16.9.31205.134 16.9.0 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
3: Visual Studio Build Tools 2019 16.8.30907.101 16.8.3 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"
4: StandAlone 17.0.0 - "c:\Users\210053326.vscode\extensions\ms-dotnettools.csharp-1.23.16.omnisharp\1.37.16.msbuild\Current\Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Community 2019 16.9.31205.134 16.9.0 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
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.Completion.CompletionOptionsProvider, 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.Cake.CakeProjectSystem
Detecting Cake files in 'c:\temp\test-app'.
info: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
info: OmniSharp.MSBuild.ProjectSystem
No solution files found in 'c:\temp\test-app'
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\temp\test-app\test-app.csproj'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\temp\test-app'.
info: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
info: OmniSharp.WorkspaceInitializer
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'c:\temp\test-app' on host 16920.
info: OmniSharp.MSBuild.ProjectManager
Loading project: c:\temp\test-app\test-app.csproj
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'c:\temp\test-app\test-app.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Adding project 'c:\temp\test-app\test-app.csproj'
info: OmniSharp.MSBuild.ProjectManager
Update project: test-app
Received response for /v2/getcodeactions but could not find request.
[warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
No symbol found. File: c:\temp\test-app\Program.cs, Line: 4, Column: 16.
[warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
No symbol found. File: c:\temp\test-app\Program.cs, Line: 7, Column: 29.

C# log

It is blank

Environment information

VSCode version: 1.61.1
C# Extension: 1.23.16

Dotnet Information .NET SDK (reflecting any global.json): Version: 6.0.100-rc.2.21505.57 Commit: ab39070116

Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\

Host (useful for support):
Version: 6.0.0-rc.2.21480.5
Commit: 6b11d64e7e

.NET SDKs installed:
3.0.100 [C:\Program Files\dotnet\sdk]
3.1.101 [C:\Program Files\dotnet\sdk]
3.1.118 [C:\Program Files\dotnet\sdk]
5.0.104 [C:\Program Files\dotnet\sdk]
5.0.202 [C:\Program Files\dotnet\sdk]
5.0.206 [C:\Program Files\dotnet\sdk]
6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
asciidoctor-vscode asciidoctor 2.8.9
beautify HookyQR 1.5.0
bracket-pair-colorizer-2 CoenraadS 0.2.1
code-spell-checker streetsidesoftware 2.0.10
cpptools ms-vscode 1.7.0
csharp ms-dotnettools 1.23.16
csharpfixformat Leopotam 0.0.84
docomment k--kato 0.1.20
dotnet-test-explorer formulahendry 0.7.7
git-graph mhutchie 1.30.0
github-vscode-theme GitHub 5.0.0
gitlens eamodio 11.6.1
jenkinsfile-support ivory-lab 1.1.0
jupyter ms-toolsai 2021.9.1101343141
jupyter-keymap ms-toolsai 1.0.0
jupyter-renderers ms-toolsai 1.0.3
LiveServer ritwickdey 5.6.1
markdown-all-in-one yzhang 3.4.0
material-theme zhuangtongfa 3.13.2
matlab Gimly81 2.2.0
mf-ide geas-platform-tools 0.1.9-mtr-50
partial-diff ryu1kn 1.4.3
pdf tomoki1207 1.1.0
powershell ms-vscode 2021.10.0
python ms-python 2021.10.1336267007
remote-containers ms-vscode-remote 0.202.4
remote-ssh ms-vscode-remote 0.65.8
remote-ssh-edit ms-vscode-remote 0.65.8
remote-wsl ms-vscode-remote 0.58.2
selectline-statusbar tomoki1207 0.0.2
theme-dracula dracula-theme 2.24.0
todo-tree Gruntfuggly 0.0.214
vscode-commons redhat 0.0.6
vscode-docker ms-azuretools 1.17.0
vscode-hexdump slevesque 1.8.1
vscode-icons vscode-icons-team 11.6.0
vscode-markdownlint DavidAnson 0.44.4
vscode-nuget-gallery patcx 0.0.24
vscode-pylance ms-python 2021.10.1
vscode-remote-extensionpack ms-vscode-remote 0.21.0
vscode-todo-highlight wayou 1.0.4
vscode-xml redhat 0.18.0
xml DotJoshJohnson 2.5.1
yang marko2276 0.1.3
@schaveyt
Copy link
Author

Looking at the log. I wonder if it has something to do with the fact that the MSBuildLocator is registering the old 16.9 rather than the new 17.0.0:
image

@schaveyt
Copy link
Author

Yup. I followed the advise of creating an omnisharp.json file in the root of the project and populating as described here et viola...it works!

{
    "msbuild": {
        "useBundledOnly": true
    }
}

@JoeRobich
Copy link
Member

Without a global.json pinning the SDK to 5.x the 6 RC2 SDK would be used during build operations. The minimal supported version of MSBuild for RC2 is 16.10. We should improve the MSBuild locator in OmniSharp-Roslyn to fallback to the Standalone MSBuild when an installed VS does not meet the minimum version requirement. Moving to OmniSharp-Roslyn.

@JoeRobich JoeRobich transferred this issue from dotnet/vscode-csharp Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants