Feel like putting my head through a wall: how can I get VS Code to use the Unity libraries?

Hi all. I am trying to get through the Beginner Scripting course, and I’ve run into a problem. The guy in the tutorial video uses MonoDevelop to edit C#. I looked into this, and it looks like this is a piece of software which is difficult to set up and/or somewhat outdated. That’s fine because I’d like to use VS Code anyway. I was able to get C# files to open in VS Code, including from Unity, but once the file is open VS Code just acts more or less like Notepad. It seems like VS Code doesn’t see the Unity libraries, so there’s no typing suggestions and no ability to ctrl-click to examine a class. I’m new to C#, so for all I know the problem may be with the setting-up of C# generally. When I open the file, I get a popup in VS Code saying:

Some projects have trouble loading. Please review the output for more details. Source: C# (Extension)

If I hit the ‘Show Output’ button, among other normal looking things, I see:

fail: OmniSharp.MSBuild.ProjectLoader: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at .NET SDKs for Visual Studio

Failed to load project file ‘c:\Users\Aidan\Desktop\RollTheBall\Assembly-CSharp.csproj’.
c:\Users\Aidan\Desktop\RollTheBall\Assembly-CSharp.csproj
C:\Users\Aidan.vscode\extensions\ms-vscode.csharp-1.21.6.omnisharp\1.34.6.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1175,5): Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at .NET SDKs for Visual Studio

Attempted to update project that is not loaded: c:\Users\Aidan\Desktop\RollTheBall\Assembly-CSharp.csproj

In no particular order, here’s all the things I can remember doing to get to this point (I’m doing this on Windows):

  • Installed .NET Framework SDK

  • Installed .NET Framework Developer Pack

  • Installed .NET Framework Targeting Pack

  • Installed the C# extension for VS Code

  • Installed the Unity Extension for VS Code

  • Opened VS Code Terminal; entered “dotnet new console”; entered “dotnet restore”

  • Installed Mono x64

  • Installed Gtk# for .net

  • Set VS Code as the external script editor in Unity

  • Tried using Visual Studio instead (same issue)

I don’t really know what most of these things are, but they are all things that people online have said are needed to edit C# scripts for Unity and/or fix this problem. I’m basically out of ideas here. Any help would be appreciated.

-Aidan

The latest versions, or the exact versions it is telling you it needs?

Regular Visual Studio or Visual Studio Community? Community should work out of the box and already be setup.

Anyway, here’s a thread

1 Like

Hi there. Problem solved. I had seen the thread you directed me to, but as I’m sure you were implying, the VS Code was telling me what was wrong with it all along. I guess the ‘newest software best software’ heuristic didn’t hold up in this case. Thank you for showing me the solution.