vscode-csharp: ProjectReference results in "type or namespace name 'System' could not be found" when Multi-Trageting
Environment data
dotnet --info
output:
.NET Command Line Tools (2.1.4)
Product Information:
Version: 2.1.4
Commit SHA-1 hash: 5e8add2190
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/2.1.4/
Microsoft .NET Core Shared Framework Host
Version : 2.0.5
Build : 17373eb129b3b05aa18ece963f8795d65ef8ea54
VS Code version: 1.20.1
C# Extension version: 1.14.0
Steps to reproduce
1- Create a mstest project 2- Open the folder in VS Code; verify there are no errors; Close the Folder 3- use DOTNET ADD to add a ProjectReference outside of root directory to the mstest project. The Reference Project must have use TargetFrameworks (multi-Target) not TargetFramework. 4- Open the folder in VS Code;
Expected behavior
No Problems/Error given that “dotnet build” works.
Actual behavior
Problem Panel displays lots of errors
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 26 (10 by maintainers)
Sorry how do we get this version in vscode? I’m on windows and see 1.17.1 for the c# extension. It appears to have omnisharp 1.31+, but it still can’t pick up
using System
and tons of errors.Here is my OmniSharp output
No, there’s no way to do that. OmniSharp really only calls the
Compile
andCoreCompile
targets, which depend on a lot of other targets. I suspect that disabling some would mean that things just don’t work.I’ve made a few fixes to OmniSharp in this area recently. In particular, we identified a problem where it would fail to handle multi-targeted projects that were referenced outside of the current solution or folder that OmniSharp was launched with. Could you try using that version and see if it helps with this particular issue? You can use it by setting
"omnisharp.path"
to"latest"
in the VS Code settings.