找不到指定的框架'Microsoft.NETCore.App'版本'2.2.0'

我正在使用Visual Studio 2019版本16.3.7。我认为这是最新的更新。

当我尝试编译基本的.NET Core 2.2控制台应用程序时:

找不到指定的框架'Microsoft.NETCore.App'版本'2.2.0'

...我收到以下错误:

It was not possible to find any compatible framework version
The specified framework 'microsoft.NETCore.App',version '2.2.0' was not found.
  - The following frameworks were found:
      1.0.1 at [C:\Program Files\dotnet\shared\microsoft.NETCore.App]
      2.0.9 at [C:\Program Files\dotnet\shared\microsoft.NETCore.App]
      2.1.11 at [C:\Program Files\dotnet\shared\microsoft.NETCore.App]
      2.1.12 at [C:\Program Files\dotnet\shared\microsoft.NETCore.App]
      2.1.13 at [C:\Program Files\dotnet\shared\microsoft.NETCore.App]
      3.0.0 at [C:\Program Files\dotnet\shared\microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The .NET Core frameworks can be found at:
  - https://aka.ms/dotnet-download .

找不到指定的框架'Microsoft.NETCore.App'版本'2.2.0'

我的理解是.NET Core 3.0向后兼容。为什么Visual Studio安装程序安装了2.2版以外的所有.NET Core版本? 我该如何解决这个问题?

mmcy588 回答:找不到指定的框架'Microsoft.NETCore.App'版本'2.2.0'

就我而言,缺少 x86 .NET Core 2.2.x平台SDK (Visual Studio .NET 16.4 + .NET Core 3.1 SDK; xUnit测试项目)。

您可以尝试以下方法:

  1. C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App中存在目录2.2.x吗?
  2. 如果否,请尝试通过以下网址下载用于 x86平台的最新版本2.2.x SDK
  3. 安装并尝试...
  4. 有关已安装的SDK和运行时的更多信息,您可以使用命令:dotnet --info
,

无论出于何种原因,“。NET Core跨平台开发”工作负载均未安装.NET Core 2.2。打开Visual Studio安装程序,然后转到“单个组件”选项卡,您可以从此处安装它:

enter image description here

,

您可以按照@Martin的说明安装x86 .NET Core 2.2.x Platform SDK。

如果不需要像我这样的x86版本,也可以设置

<PlatformTarget>AnyCPU</PlatformTarget>

 <PlatformTarget>x64</PlatformTarget>

在主项目和测试项目的.csproj文件中

为避免此问题。

,

因为您的计算机上未安装Asp.Net core运行时。要安装2.2版,您可以按照this q&a的指南进行操作。

,

对于那些尝试将文件部署到非开发人员机器上的用户,您会看到此错误,请对文件夹配置文件使用“项目”->“发布”选项,并将设置更新为“部署模式:自包含”。然后“发布”它。

这会将运行时嵌入到.exe中,使其变得更大,但也很容易在客户端计算机上“正常工作”。

enter image description here

,

有两个选项可以运行Visual Studio Update应用程序,以查看是否将为您安装任何缺少的要求,或者从https://dotnet.microsoft.com/download/dotnet-core/2.2(或https://aka.ms/dotnet-download中手动安装net core 2.2 SDK,如错误消息。)

,

.NET Core 2.2.0不再受支持。 等待.NET 5

本文链接:https://www.f2er.com/3163337.html

大家都在问