Open DustinCampbell opened 6 years ago
The issue here is that OmniSharp picks the first target framework when there are multiple TFMs. So, it's MSBuild is trying process your project as net461, but that isn't installed on your Mac. There are a couple of options here:
From @CaulyKan on July 31, 2018 17:35
After changed the csproj to <TargetFrameworks>netstandard2.0;net461;net452</TargetFrameworks>
it worked.
But however is it possible to try the next TFM in order when the current one fails? or more easily, write the instruction in error message?
Thanks a lot.
PS. Current error message: The reference assemblies for framework ".NETFramework,Version=v4.6.1" 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.
It's harder than you might think to detect this scenario. The message actually comes from MSBuild as part of the process of building your project. However, I think we should probably try to do something. I'll move this over to the omnisharp-roslyn repo where that work would need to happen.
Could there be some mechanism (environment variable, configuration file, etc) that allows me to specify the framework that I want to use?
From @CaulyKan on July 31, 2018 16:7
Environment data
dotnet --info
output: .NET Core SDK (reflecting any global.json): Version: 2.1.302 Commit: 9048955601Runtime Environment: OS Name: Mac OS X OS Version: 10.13 OS Platform: Darwin RID: osx.10.13-x64 Base Path: /usr/local/share/dotnet/sdk/2.1.302/
Host (useful for support): Version: 2.1.2 Commit: 811c3ce6c0
.NET Core SDKs installed: 2.1.302 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
VS Code version: 1.25.1 C# Extension version: 1.15.2
Steps to reproduce
Create a project:
Expected behavior
Omnisharp gives a warning rather than error for "The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. "; Functions such as codelens should still be functional.
Actual behavior
Omnisharp gives an error for "The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. "; Functions such as codelens no longer works.
Copied from original issue: OmniSharp/omnisharp-vscode#2444