vscode-csharp: New files showing type or namespace not found but it is their

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.21.1 C# Extension version: 1.14.0

Steps to reproduce

Create a new file after loading a Unity Project

Expected behavior

No Error

Actual behavior

The editor is showing red line with type or namespace could not be found when it is actually their. I can go to definition and it loads the right file, the code compiles and executes properly in Unity.

screen shot 2018-03-25 at 9 11 31 am

Not sure what could cause this. I know if I do:

dotnet build Assembly-CSharp.csproj

I get the following error (same error when I do a build on any of the Unity csproj files):

Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Nothing to do. None of the projects specified contain packages to restore.
/usr/local/share/dotnet/sdk/2.1.4/Microsoft.Common.CurrentVersion.targets(1124,5): error 
MSB3644: The reference assemblies for framework ".NETFramework,Version=v3.5" were 
not found. To resolve this, install the SDK or Targeting Pack for this framework version or 
retarget your application to a version of the framework for which you have the SDK or 
Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly 
Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly 
may not be correctly targeted for the framework you intend. 
[/repositories/arpg-project/Assembly-CSharp.csproj]

Build FAILED.

/usr/local/share/dotnet/sdk/2.1.4/Microsoft.Common.CurrentVersion.targets(1124,5): error 
MSB3644: The reference assemblies for framework ".NETFramework,Version=v3.5" were 
not found. To resolve this, install the SDK or Targeting Pack for this framework version or 
retarget your application to a version of the framework for which you have the SDK or 
Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly 
Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly 
may not be correctly targeted for the framework you intend. 
[/repositories/arpg-project/Assembly-CSharp.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.60

However I don’t seem to see that error in the vscode output logs (I only get this when I run dotnet manually). I have tried this with both 5.8.0 and 5.10.0 of Mono installed and can’t figure it out.

This same code / project load fine and shows no errors in Rider.

Any help in trying to debug this would be awesome.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (2 by maintainers)

Most upvoted comments

For those following along here, feel free to file an issue using the command “CSharp: report an issue” from VS Code.