8
votes

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

1
Have you installed .NET Core SDK 3.0.100-preview-010184? Try to run command dotnet --version to see the current sdk. I made a test with VS Code, it opens the project correctly.Edward
I have installed .NET Core SDK 3.0.100-preview4-010525. Using 2.2.1. is working correctly.Marco Duindam
You should use visual studio and not visual studio code. It is a .net core project, right?Carlos Jafet Neto
Do you have visual studio 2019 preview as well? I think you need that. Then make sure any old NuGet packages for an older SDK version uninstalled.user9105725
dotnet.microsoft.com/download/dotnet-core/3.0... warning banner shows what relates to my previous comment.user9105725

1 Answers

9
votes

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.