42
votes

I am using Visual Studio 2019 Version 16.3.7. I assume it is the latest update.

When I try to compile a basic .NET Core 2.2 console application:

enter image description here

...I get the following error:

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 .

enter image description here

My understanding is that .NET Core 3.0 is backward compatible. Why Visual Studio installer installed all versions of .NET Core except 2.2? How do I solve this problem?

7
when 3.0 framework is installed shouldn't you be able to build .net core 2.2 application? - SharpCoder

7 Answers

62
votes

For whatever reason, .NET Core 2.2 is not installed by the ".NET Core cross-platform development" workload.

Open up the Visual Studio installer then go to the "Individual components" tab and you can install it from there:

enter image description here

enter image description here

enter image description here

32
votes

In my case was missing x86 .NET Core 2.2.x Platform SDK (Visual Studio .NET 16.4 + .NET Core 3.1 SDK ; xUnit Test Project).

You can try this:

  1. Exist directory 2.2.x in: C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App ?
  2. When no, try Download latest 2.2.x SDK for x86 platform from this URL: https://dotnet.microsoft.com/download/dotnet-core/2.2
  3. Install and try ...
  4. For more info about installed SDK and Runtime you can use command: dotnet --info
3
votes

For those trying to deploy a file to a non-developer machine and you see this error, use the Project -> Publish option with a Folder Profile and update the settings to be "Deployment mode: Self-contained". Then "Publish" it.

This will embed the runtime into the .exe, making it much larger, but also simple to "just work" on a client machine.

enter image description here

1
votes

You can install x86 .NET Core 2.2.x Platform SDK as @Martin said.

If you do not need x86 version like me, you can also set

<PlatformTarget>AnyCPU</PlatformTarget>

to

 <PlatformTarget>x64</PlatformTarget>

in both main project and test project 's .csproj file

to avoid this problem.

0
votes

Two options are to run the Visual Studio Update application to see if any missing requirements will be installed for you or to install the net core 2.2 SDK manually from https://dotnet.microsoft.com/download/dotnet-core/2.2 (or https://aka.ms/dotnet-download as mentioned in the error message).

0
votes

Because Asp.Net core runtime is not installed on your computer. To install version 2.2 you can do follow by the guide of this q&a.

-3
votes

.NET Core 2.2.0 is not supported anymore. Waiting for the .NET 5