dotnet --info output:
.NET Command Line Tools (2.1.200)
Product Information:
Version: 2.1.200
Commit SHA-1 hash: 2edba8d7f1
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.200\
Microsoft .NET Core Shared Framework Host
Version : 2.0.7
Build : 2d61d0b043915bc948ebf98836fefe9ba942be11
VS Code version: 1.23.1
C# Extension version: 1.15.1 (OmniSharp 1.30.0)
After opening an existing project, all source files in the project are flagged with these errors (types and namespaces can be treated as wildcards as all predefined types, top-level namespaces, and types imported from referenced packages or the framework itself are error-flagged):
Per issue #1855 I do have a valid and up to date install of Visual Studio 2017 Community as selected by OmniSharp:
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Community 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
2: StandAlone 15.0 - "C:\Users\Chris\.vscode\extensions\ms-vscode.csharp-1.15.1\.omnisharp\1.30.0\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Community 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
I've confirmed that the path to MSBuild for VS 2017 exists and contains a functional install of MSBuild.
Predefined types, and both namespaces and types from referenced packages would not be marked as errors.
Red squigglies. Red squigglies everywhere. And every source file in the project shown in red in the workspace explorer pane.
@coldacid Does your project do any multitargeting (per https://github.com/OmniSharp/omnisharp-vscode/issues/2095 ) ?
@rchande No, it's solely targeted to net462.
Are there any errors or warnings in your OmniSharp Log?
Nothing but info messages. Path names changed to protect the innocent.
Starting OmniSharp server at 2018-5-14 16:27:10
Target: c:\Users\Chris\Work\PROJECT-NAME\PROJECT-NAME.sln
OmniSharp server started
Path: C:\Users\Chris\.vscode\extensions\ms-vscode.csharp-1.15.1\.omnisharp\1.30.0\OmniSharp.exe
PID: 29564
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Community 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
2: StandAlone 15.0 - "C:\Users\Chris\.vscode\extensions\ms-vscode.csharp-1.15.1\.omnisharp\1.30.0\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Community 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'c:\Users\Chris\Work\PROJECT-NAME'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
Initializing in c:\Users\Chris\Work\PROJECT-NAME
[info]: OmniSharp.DotNet.DotNetProjectSystem
Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
Resolving projects references
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 'c:\Users\Chris\Work\PROJECT-NAME\PROJECT-NAME.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Users\Chris\Work\PROJECT-NAME\PROJECT-NAME.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: c:\Users\Chris\Work\PROJECT-NAME\PROJECT-NAME.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\Users\Chris\Work\PROJECT-NAME'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.Stdio.Host
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Stdio.Host
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'c:\Users\Chris\Work\PROJECT-NAME' on host 28548.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project 'c:\Users\Chris\Work\PROJECT-NAME\PROJECT-NAME.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: PROJECT-NAME
[info]: OmniSharp.MSBuild.ProjectManager
Found referenced project outside root directory: c:\Users\Chris\Repos\structurizr-dotnet\Structurizr.Annotations\Structurizr.Annotations.csproj
@coldacid And just to confirm, you are able to dotnet restore and dotnet build without errors?
@rchande That is correct.
I encounter the same bug when using vscode version 1.23.1 to open coreapp2.0 project. However, opening a netstandard2.0 project doesn't trigger this bug.
I just remembered that one of the referenced projects _is_ multi-targeted, but not my main project, in case that makes a difference.
That may make a difference. I suspect this is the same issue as https://github.com/OmniSharp/omnisharp-vscode/issues/2095. Is there any chance that you'd be willing to share your project with us to reproduce the issue?
It's not my place to make the decision to share, but I'll try and put together a repro case project when I get home tonight.
That would be fantastic. Thanks!
Here's the repro. It looks like it might very well be the reference to the multi-targeted external project; commenting out the <ProjectReference/> tag for it and reloading OmniSharp makes the problem go away in this repro, while leaving it as-is causes the error.
When trying the repro please make sure to clone the external projects as described in the readme file inside the zip.
Thanks very much for the repro. I can definitely reproduce the issue. This will be very helpful.
Again, thanks very much for the repro. I have a fix prototyped.
The fix for this has been pushed into OmniSharp. You should be able to get the fix by setting the "omnisharp.path" option in VS Code to "latest". That will cause C# for VS Code to download the latest build OmniSharp at start up.
Thanks!
Most helpful comment
The fix for this has been pushed into OmniSharp. You should be able to get the fix by setting the
"omnisharp.path"option in VS Code to"latest". That will cause C# for VS Code to download the latest build OmniSharp at start up.