Search Unity

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

Discussion in 'Getting Started' started by AidanofVT, Nov 10, 2019.

  1. AidanofVT

    AidanofVT

    Joined:
    Nov 10, 2019
    Posts:
    104
    This problem was solved by a user in the scripting sub-forum, where I had put a duplicate thread. Mods, please delete this thread.

    Hi all. I am trying to get through the Beginner Scripting course, and I've run into a problem. When I open a C# file from within Unity, it does open the file in VS Code as I'd want it to, but then it 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 I may have done something wrong with that installation. 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 https://aka.ms/msbuild/developerpacks

    [warn]: OmniSharp.MSBuild.ProjectManager
    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 https://aka.ms/msbuild/developerpacks

    [fail]: OmniSharp.MSBuild.ProjectManager
    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
    • Installed Mono x64
    • Installed Gtk# for .net
    • Set VS Code as the external script editor in Unity
    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
     
    Last edited: Nov 10, 2019