dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 673 forks source link

Error: The reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found #2808

Open heaversm opened 5 years ago

heaversm commented 5 years ago

Environment data

dotnet --info output: 2.2.1 VS Code version: C# Extension version: 1.17.1

Steps to reproduce

Try to use the Unity Debugger. Error gets thrown in VSCode

Expected behavior

No errors

Actual behavior

Errors on startup

The .NETFramework is not available on a Mac. I'm not sure if it is needed for this extension - if it is, the extension is useless on Mac. If it is not, there should be a check for the platform or something. Regardless, if I try to debug Unity, it crashes as soon as I hit play (Debug adapter process has terminated unexpectedly (spawn mono ENOENT)

rchande commented 5 years ago

@heaversm You need to install mono (https://www.mono-project.com/download/stable/#download-mac). I recommend installing version 5.18 from that page instead of using homebrew/etc package managers. (copied from https://github.com/OmniSharp/omnisharp-vscode/issues/2555#issuecomment-456998688)

heaversm commented 5 years ago

I installed mono: mono --version : Mono JIT compiler version 5.16.0.221. I believe at this point I have tried both brew and a direct download - do you know how to use the version over the brew version?

batbaatap commented 4 years ago

Did you install Mono framework and .net core, if so write on your terminal below: export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current

jscheel commented 4 years ago

I know I'm resurrecting a year old thread, but I'm running into the same issue. I have latest mono installed, I've exported FrameworkPathOverride, but I still end up with the same error.

JoeRobich commented 4 years ago

@jscheel can you share the OmniSharp Log from the project you are working on?

DTX-92 commented 4 years ago

can you share the OmniSharp Log from the project you are working on?

Same issue =\

https://github.com/OmniSharp/omnisharp-vscode/issues/3063#issuecomment-642598877

Starting OmniSharp server at 6/11/2020, 3:26:22 PM
    Target: /Users/dtx/Dev/_unity/myProject/MyProject/MyProject.sln

OmniSharp server started.
    Path: /Users/dtx/.vscode/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/run
    PID: 575

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.14.6 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.4 - "/Users/dtx/.vscode/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/Users/dtx/.vscode/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.4 - "/Users/dtx/.vscode/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/omnisharp/.msbuild/Current/Bin"
            CscToolExe = csc.exe
            MSBuildToolsPath = /Users/dtx/.vscode/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/omnisharp/.msbuild/Current/Bin
            CscToolPath = /Users/dtx/.vscode/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/omnisharp/.msbuild/Current/Bin/Roslyn
            BypassFrameworkInstallChecks = true
            MSBuildExtensionsPath = /Users/dtx/.vscode/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/dtx/Dev/_unity/myProject/MyProject'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/Users/dtx/Dev/_unity/myProject/MyProject/MyProject.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/dtx/Dev/_unity/myProject/MyProject/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/dtx/Dev/_unity/myProject/MyProject/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/dtx/Dev/_unity/myProject/MyProject'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/dtx/Dev/_unity/myProject/MyProject/Assembly-CSharp.csproj
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/dtx/Dev/_unity/myProject/MyProject' on host 558.
[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 '/Users/dtx/Dev/_unity/myProject/MyProject/Assembly-CSharp.csproj'.
/Users/dtx/Dev/_unity/myProject/MyProject/Assembly-CSharp.csproj
/Users/dtx/.vscode/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1193,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

[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/dtx/Dev/_unity/myProject/MyProject/Assembly-CSharp-Editor.csproj
[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 '/Users/dtx/Dev/_unity/myProject/MyProject/Assembly-CSharp-Editor.csproj'.
/Users/dtx/Dev/_unity/myProject/MyProject/Assembly-CSharp-Editor.csproj
/Users/dtx/.vscode/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1193,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: /Users/dtx/Dev/_unity/myProject/MyProject/Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: /Users/dtx/Dev/_unity/myProject/MyProject/Assembly-CSharp-Editor.csproj
bmschwartz commented 4 years ago

Try adding export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current to your ~/.bash_profile or ~/.zshrc or whichever terminal you use. Restart VSCode before trying again.

DTX-92 commented 4 years ago

@bmschwartz You are my hero! When I moved FrameworkPathOverride from the global PATH to .bash_profile, OmniSharp started with no errors

bmschwartz commented 4 years ago

Glad I could help. I spent a few hours trying to figure it out as well.

Ariel-Feldman commented 4 years ago

@bmschwartz Bro, you're like an archangel bringing this solution to us!

marcinwalus commented 4 years ago

Try adding export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current to your ~/.bash_profile or ~/.zshrc or whichever terminal you use. Restart VSCode before trying again.

That worked for me too! Thank you very much!

MrRobert91 commented 4 years ago

Try adding export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current to your ~/.bash_profile or ~/.zshrc or whichever terminal you use. Restart VSCode before trying again.

Worked for me on ubuntu 20.04 I added the line to my ~/.bashrc and the restarted visual studio code

Thanks a lot!!

Mangi91 commented 3 years ago

@bmschwartz that was it! Thanks!

o8ruza8o commented 3 years ago

How can that possibly work on Ubuntu 20.04? It is a MacOS path to mono framework which does not exist on Ubuntu.

kentliau commented 3 years ago

Try adding export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current to your ~/.bash_profile or ~/.zshrc or whichever terminal you use. Restart VSCode before trying again.

this is it, thanks @bmschwartz .

Sakari369 commented 3 years ago

Just clarifying that for me I needed to put this "export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current" to ~/.bash_profile.

I dont use bash as my shell, but seems it is loading it from there anyway on macOS.