vscode-csharp: Visual Studio Code for Unity: "The reference assemblies for .NETFramework,Version=v4.7.1 were not found. ... "

Environment data

dotnet --info output:

.NET SDK (reflecting any global.json): Version: 5.0.102 Commit: 71365b4d42

Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/5.0.102/

Host (useful for support): Version: 5.0.2 Commit: cb5f173b96

.NET SDKs installed: 5.0.102 [/usr/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 5.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

VS Code version: 1.52.1 C# Extension version: v1.23.8

OmniSharp log

Starting OmniSharp server at 1/15/2021, 4:21:50 PM Target: /home/simon_rober/CS02 - Introduction to Unity/CS02 - Introduction to Unity.sln

OmniSharp server started. Path: /home/simon_rober/.vscode/extensions/ms-dotnettools.csharp-1.23.8/.omnisharp/1.37.5/run PID: 38730

    Starting OmniSharp on ubuntu 20.4 (x64)
    DotNetPath set to dotnet
    Located 1 MSBuild instance(s)
        1: StandAlone 16.8.0 - "/home/simon_rober/.vscode/extensions/ms-dotnettools.csharp-1.23.8/.omnisharp/1.37.5/omnisharp/.msbuild/Current/Bin"
    MSBUILD_EXE_PATH environment variable set to '/home/simon_rober/.vscode/extensions/ms-dotnettools.csharp-1.23.8/.omnisharp/1.37.5/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
    Registered MSBuild instance: StandAlone 16.8.0 - "/home/simon_rober/.vscode/extensions/ms-dotnettools.csharp-1.23.8/.omnisharp/1.37.5/omnisharp/.msbuild/Current/Bin"
        CscToolExe = csc.exe
        MSBuildToolsPath = /home/simon_rober/.vscode/extensions/ms-dotnettools.csharp-1.23.8/.omnisharp/1.37.5/omnisharp/.msbuild/Current/Bin
        CscToolPath = /home/simon_rober/.vscode/extensions/ms-dotnettools.csharp-1.23.8/.omnisharp/1.37.5/omnisharp/.msbuild/Current/Bin/Roslyn
        BypassFrameworkInstallChecks = true
        MSBuildExtensionsPath = /home/simon_rober/.vscode/extensions/ms-dotnettools.csharp-1.23.8/.omnisharp/1.37.5/omnisharp/.msbuild
    Detecting Cake files in '/home/simon_rober/CS02 - Introduction to Unity'.
    Could not find any Cake files
    Detecting projects in '/home/simon_rober/CS02 - Introduction to Unity/CS02 - Introduction to Unity.sln'.
    Queue project update for '/home/simon_rober/CS02 - Introduction to Unity/Assembly-CSharp.csproj'
    Detecting CSX files in '/home/simon_rober/CS02 - Introduction to Unity'.
    Could not find any CSX files
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Loading project: /home/simon_rober/CS02 - Introduction to Unity/Assembly-CSharp.csproj
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
    Configuration finished.
    Omnisharp server running using Stdio at location '/home/simon_rober/CS02 - Introduction to Unity' on host 38583.
    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
    Failed to load project file '/home/simon_rober/CS02 - Introduction to Unity/Assembly-CSharp.csproj'.

/home/simon_rober/CS02 - Introduction to Unity/Assembly-CSharp.csproj /home/simon_rober/.vscode/extensions/ms-dotnettools.csharp-1.23.8/.omnisharp/1.37.5/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1180,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

    Attempted to update project that is not loaded: /home/simon_rober/CS02 - Introduction to Unity/Assembly-CSharp.csproj

Steps to reproduce

I desire to use unity and want to edit the C# files with VS Code on Ubuntu 20.04, hence I took a look at this tutorial: https://code.visualstudio.com/docs/other/unity

I installed .Net: dotnet --info: ".NET SDK (reflecting any global.json): Version: 5.0.102 Commit: 71365b4d42

Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/5.0.102/

Host (useful for support): Version: 5.0.2 Commit: cb5f173b96

.NET SDKs installed: 5.0.102 [/usr/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 5.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download"

Further I installed the C# extension to VS Code and managed to succesfully alter the External Script Editor to VS Code. By double clicking on the script in Unity, VS Code automatically openend with the script and the extra files as expected.

Expected behavior

intellisense should work and the extension should not fail.

Actual behavior

When I started to program I noticed that Intellisence for Unity does not work. There also appeared a the above error output.

Already tried:

I already tried to change " <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>" to " <TargetFrameworkVersion>v5.0.2</TargetFrameworkVersion>" in the Assembly-CSharp.csproj file. This did not alter the behavior.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

I am also a unity User and the solution is pretty simple. Omnisharp is asking you to download the .net Framework Developers pack so that You can develop apps in C#. Here is the link to download it.

Hope this helps.😀

For lost travelllers you need to set "omnisharp.useGlobalMono": "always" in VSCode settings otherwise it doesn’t work in Mac… seems like kind of an important thing but it’s tucked away in a Changelog.

And for Mac users you need to correct the version in .csproj, at the time of writing change it to 4.8 instead of 4.7.1.

@simonrober For Linux you will want to install the stable Mono and set “omnisharp.useGlobalMono” to “always”. https://www.mono-project.com/download/stable/#download-lin

You can find the .NET Framework 4.7.1 developer pack at https://dotnet.microsoft.com/download/dotnet-framework/net471

I am on Linux. What I did to solve the issue was:

  1. Uninstalled VS Code C# extension
  2. Updated mono and mono-msbuild
  3. Reinstalled C# extension
  4. Set omnisharp.useModernNet to false in VS Code Settings
  5. Restart VS Code