[英]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? 如何在Visual Studio代码中修复.Net Core 3.0项目中的错误?
I have downloaded the .NET Core 3.0 SDK from created new project with dotnet new command in a folder. 我已经在一个文件夹中使用dotnet new命令从创建的新项目下载了.NET Core 3.0 SDK。
Opening the project with Visual Studio Code gives the following error: 使用Visual Studio Code打开项目会出现以下错误:
[fail]: OmniSharp.MSBuild.ProjectLoader The current .NET SDK does not support targeting .NET Core 3.0.
[fail]:OmniSharp.MSBuild.ProjectLoader当前的.NET SDK不支持以.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.
可以是.NET Core 2.2或更低版本,也可以使用支持.NET Core 3.0的.NET SDK版本。 [warn]: OmniSharp.MSBuild.ProjectManager Failed to load project file 'c:\\Users\\Marco\\source\\Workspaces\\WebDevelopment\\Samples\\hello-world\\hello-world.csproj'.
[warn]:OmniSharp.MSBuild.ProjectManager无法加载项目文件'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.
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):错误:当前的.NET SDK不支持以.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.
可以是.NET Core 2.2或更低版本,也可以使用支持.NET Core 3.0的.NET SDK版本。
[fail]: OmniSharp.MSBuild.ProjectManager Attemped to update project that is not loaded: c:\\Users\\Marco\\source\\Workspaces\\WebDevelopment\\Samples\\hello-world\\hello-world.csproj
[fail]:OmniSharp.MSBuild.ProjectManager尝试更新未加载的项目:c:\\ Users \\ Marco \\ source \\ Workspaces \\ WebDevelopment \\ Samples \\ hello-world \\ hello-world.csproj
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
. 我有OmniSharp使用
.NET CORE 3.0.100-preview3-010431
preview3-010431处理可视代码,麻烦似乎来自OmniSharp.MSBuild.Discovery.MSBuildLocator
使用的MSBuild版本。
In Visual Code, Look at your OmniSharp Log : 在Visual Code中,查看OmniSharp日志:
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. 不确定你会不会喜欢这个解决方案,但是在OmniShart日志中,我读到它使用的是Visual Studio 2017 MSBuild,并且因为我在VS 2017中遇到了.net Core Preview 3项目的问题,所以我安装了Visual Studio社区2019年RC。 My code .NET CORE 3.0 works on VS 2019, but I steel have troubles with OmniSharp in Visual Code.
我的代码.NET CORE 3.0适用于VS 2019,但我在Visual Code中使用OmniSharp时遇到了麻烦。 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. 为了让它在可视代码中工作,我只需将
C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\MsBuild
重命名为C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild.disabled
,在使用.NET Core的Visual Code上一切正常。
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. 结论: Omnisharp似乎需要一个支持.net Core 3.0的MSBuild。 I can't find it anywhere else than in VS 2019.
除了VS 2019之外,我无法在其他任何地方找到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.