Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Visual Studio Code and Omnisharp Extension with .Net Core SDK 3.0 preview

How do I fix the error in .Net Core 3.0 project in Visual Studio Code?

I have downloaded the .NET Core 3.0 SDK from created new project with dotnet new command in a folder.

Opening the project with Visual Studio Code gives the following error:

[fail]: OmniSharp.MSBuild.ProjectLoader The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0. [warn]: OmniSharp.MSBuild.ProjectManager Failed to load project file 'c:\Users\Marco\source\Workspaces\WebDevelopment\Samples\hello-world\hello-world.csproj'. c:\Users\Marco\source\Workspaces\WebDevelopment\Samples\hello-world\hello-world.csproj C:\Program Files\dotnet\sdk\2.2.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): Error: The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0.

[fail]: OmniSharp.MSBuild.ProjectManager Attemped to update project that is not loaded: c:\Users\Marco\source\Workspaces\WebDevelopment\Samples\hello-world\hello-world.csproj

like image 606
Marco Duindam Avatar asked Feb 26 '19 10:02

Marco Duindam


People also ask

What is OmniSharp in Vscode?

OmniSharp is a set of tooling, editor integrations and libraries that together create an ecosystem that allows you to have a great programming experience no matter what your editor and operating system of choice may be.

Does Visual Studio use OmniSharp?

C# for Visual Studio Code (powered by OmniSharp) This extension provides the following features inside VS Code: Lightweight development tools for . NET Core.

Does Visual Studio 2019 include .NET Core SDK?

As you have seen, Visual Studio 2019 installer includes . NET Core 2.1 but not . NET Core 3.


1 Answers

Not a solution, but a workaround for me :

I have OmniSharp working on Visual code with .NET CORE 3.0.100-preview3-010431 the trouble seems to come from the version of MSBuild used by OmniSharp.MSBuild.Discovery.MSBuildLocator.

In Visual Code, Look at your OmniSharp Log :

enter image description here

Not sure that you'll like the solution, but in the OmniShart Log, I read that it was using Visual Studio 2017 MSBuild, and as I met a problem with .net Core Preview 3 project in VS 2017, so I installed Visual Studio Community 2019 RC. My code .NET CORE 3.0 works on VS 2019, but I steel have troubles with OmniSharp in Visual Code. To have it work in visual code I just rename C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MsBuild to C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild.disabled, and all is OK on Visual Code with .NET Core.

    Located 3 MSBuild instance(s)
        1: Visual Studio Enterprise 2017 15.9.28307.344 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"
        2: Visual Studio Community 2019 16.0.28714.193 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
        3: StandAlone 15.0 - "c:\Users\JPB\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
    Registered MSBuild instance: Visual Studio Enterprise 2017 15.9.28307.344 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"

Becomes :

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Community 2019 16.0.28714.193 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
            2: StandAlone 15.0 - "c:\Users\JPB\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2019 16.0.28714.193 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"

Conclusion : Omnisharp seems to need a MSBuild that support .net Core 3.0. I can't find it anywhere else than in VS 2019.

like image 150
JPBlanc Avatar answered Sep 22 '22 06:09

JPBlanc