c# - dotnet core 3.0在vs中打开解决方案时无法找到dotnetcore sdk

标签 c# asp.net-core asp.net-core-3.0

我正在尝试加载 ASP.NET Core MVC 的源代码 https://github.com/aspnet/aspnetcore 。但是,当我克隆项目、 checkout v3.0.0 并尝试在 Visual Studio 2019 (v16.3.4) 中打开解决方案时,所有项目均出现以下错误

Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version

我已确保 .net core 3.0 sdk 已下载到我的计算机上,并且运行 dotnet --info 会生成以下数据:

Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

查看.csproj文件,它们都是针对的

<TargetFramework>netcoreapp3.0</TargetFramework>

此外,我已确保 SDK 'C:\Program Files\dotnet' 的路径包含在我的 PATH 变量中。我尝试添加指定 sdk 的 global.json 文件,但似乎没有什么区别。

知道什么可能导致此问题吗?

编辑

下面是 csproj 文件的示例

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <Description>ASP.NET Core metadata.</Description>
    <TargetFramework>netstandard2.0</TargetFramework>
    <IsAspNetCoreApp>true</IsAspNetCoreApp>
    <IsShippingPackage>true</IsShippingPackage>
    <NoWarn>$(NoWarn);CS1591</NoWarn>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <PackageTags>aspnetcore</PackageTags>
  </PropertyGroup>

</Project>

,这是我的机器上包含所有 SDK 的文件夹。 enter image description here

最佳答案

我有同样的问题,我找到了解决方案; 我希望你和我有同样的问题。

cmd -> 输入dotnet --info
复制.Net Core的“基本路径”
只需将其添加到系统的 Path 变量中即可。

变量名称为MSBuildSdksPath

更多详情,可以查看这个https://github.com/aspnet/Announcements/issues/231

关于c# - dotnet core 3.0在vs中打开解决方案时无法找到dotnetcore sdk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58379226/

相关文章:

c# - 绑定(bind)到 ASP.NET MVC 中的强类型对象集合

c# - 在多线程应用程序中使用 MessageBox 显示异常信息

c# - String.Intern 和 String.IsInterned 有什么区别?

javascript - 在 ASP Net CORE MVC 元素中使用 Google Material UI

c# - 使用 Asp.NET Core 3.1 框架将文件上传到服务器时如何使用 IFormFile 作为属性?

c# - 在 C# 中将 APRIL, 03/2013 字符串转换为 DateTime

c# - Visual Studio Code : How to configure 'dotnet' not to show warnings when compiling

c# - 自动生成的 c# 客户端应该如何处理可以返回不同类型的 API 调用?

.net - 无法在 Blazor 中的 URL 参数中使用越南语/签名字符和空格字符

c# - 进程内和进程外托管的 ASP .NET Core 3 + Identity Server 问题