The specified framework 'Microsoft.NETCore.App', version '2.2.0' was not found

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?


Solution 1:

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

Solution 2:

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

Solution 3:

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