关于c#:将Visual Studio 2017与.Net Core SDK 3.0一起使用

Use Visual Studio 2017 with .Net Core SDK 3.0

如何在Visual Studio 2017中打开.Net Core 3.0项目?

我已经从dotnet.microsoft.com下载了.NET Core 3.0 SDK,并在文件夹中使用dotnet new命令创建了新项目。

构建C#项目显示错误:

The current .NET SDK does not support targeting .NET Core 3.0. Either
target .NET Core 2.1 or lower, or use a version of the .NET SDK that
supports .NET Core 3.0.

我检查了一下,但在我的情况下不起作用:

带有.Net Core SDK 2.0的Visual Studio 2017

带有.Net Core SDK 2.1的Visual Studio 2017


在VS 2017中:您可以转到工具→选项→项目和解决方案→.NET Core,然后选中使用.NET Core SDK的预览


不幸的是.NET Core 3需要MSBuild16。即使您在VS 2017中启用了.NET Core的预览版本(如其他人所建议的那样),您仍然会收到错误:

The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.0.

如果创建global.json文件并放入例如。

1
2
3
4
5
{
 "sdk": {
   "version":"3.0.100-preview5-011568"
  }
}

然后,您会看到真正的问题是:

error : Version 3.0.100-preview5-011568 of the .NET Core SDK requires at least version 16.0.0 of MSBuild. The current available version of MSBuild is 15.9.21.664. Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.`

MSBuild 16仅随VS 2019一起提供,因此答案是您可以将VS 2017与.NET Core 3一起使用,但前提是您还必须安装VS 2019!


Visual Studio 2019更新

关于@GoDev的原始答案:

Starting with Visual Studio 2019, the option has moved to:

Tools > Options > Environment > Preview Features

Option screen

官方说明


遇到相同的问题,这篇文章有助于理清

1.检查是否安装了.NET Core SDK 3.x

enter image description here

如果没有,请转至.NET Core 3官方下载页面并获取它,然后安装并重试。
https://dotnet.microsoft.com/download/dotnet-core/3.0

2.启用.NET Core SDK预览

enter image description here

3.使用Visual Studio 2019

.NET Core 3.0 Preview1是可与Visual Studio 15.9(aka Visual Studio 2017)一起使用的.NET Core 3.0的最新版本:.NET Core 3.0的任何后续发行版(包括夜间应用程序)都要求VS 16.0+,也称为Visual Studio 2019。您具有Visual Studio 2017,请安装VS2019,然后重试。

4.检查PATH环境变量

enter image description here

参考:https://www.ryadel.com/cn/current-net-sdk-not-support-net-core-3-0-fix/


您需要从以下位置启用"使用.NET Core SDK的预览"

Visual Studio's tools | Options | Project and Solutions | .NET Core

此后,您需要重新启动Visual Studio,并且将能够使用" .NET Core 3"项目。

您也可以关注youtube页面,以获取有关" .NET Core 3"的任何其他查询。


若要创建或打开面向.NET Core 3.0的应用程序,需要Visual Studio 2019或更高版本。
在创建新项目时,Visual Studio可能会显示一个黄色条,并显示消息"此版本的Visual Studio不支持ASP.NET Core 3.0或更高版本的项目"

更多信息:
https://github.com/aspnet/Tooling/blob/master/dotnet-core-3.0-preview1.md


.Net Core 3.0需要Visual Studio 2019预览版1,您不能使用Visual Studio2017。根据.Net博客," Visual Studio 2019将成为支持构建.NET Core 3应用程序的版本",并且需要.Net 4.8

在创建新的应用程序/项目时,该项目通过netcorepp3.0目标框架声明对.Net Core 3.0的依赖。


在最新版与预览版中已修复此问题。按照此处的步骤进行安装。
https://docs.microsoft.com/zh-cn/visualstudio/mac/install-preview?view=vsmac-2019