简体   繁体   中英

It was not possible to find any compatible framework version. The specified framework 'Microsoft.NETCore.App', version '2.2.0' was not found

I had a .Net Core console app built and deployed.

The project's Platform target is x86.

Target framework is .Net Core 2.2(x86).

Although .Net Core 2.2 (x86) SDK is installed, I get following error after executing the command dotnet myapp.dll in Developer Command Prompt VS2017.

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 versions are installed:
2.0.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

The .Net Core 2.2(x86) SDK was installed under path "C:\Program Files (x86)\dotnet\shared", and System Environment Variables contains "C:\Program Files (x86)\dotnet\".

Any suggestion? Thanks!

~~~Update1

Following are part of .csproj info, sorry can't show whole thing.

 <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp2.2</TargetFramework> <Platforms>AnyCPU;x86;x64</Platforms> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <PlatformTarget>x86</PlatformTarget> <Prefer32Bit>true</Prefer32Bit> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PlatformTarget>x64</PlatformTarget> <Prefer32Bit>true</Prefer32Bit> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'"> <PlatformTarget>x86</PlatformTarget> </PropertyGroup>

After searching through Microsoft documentation, I noticed that I was missing an additional required Nugget package.

The documentation says:

Before you can use the tools on a specific project, you'll need to add the Microsoft.EntityFrameworkCore.Design package to it.

This is what I did by adding the package

$ dotnet add package Microsoft.EntityFrameworkCore.Design

Some months ago a Visual Studio update broke my capability of running tests. One of the issues was exactly this error. I have the x64 version of the SDK installed but VS tests runner was attempting to use the x86 version. The fix is just changing a setting inside the Test Explorer: Processor Architecture for AnyCPU Projects -> x64 .

在此处输入图像描述

It seem to be a known issue for .Net Core installation, github.com/dotnet/core-setup/issues/4350

I have to uninstall all .Net Core packages, both x64 and x86, then reinstalled .Net Core x86 package. And that solved the problem.

This error also happened to me, and the answer I found was very easy, => in my solution I had two projects and a class library, the data folder was in the API project, in the case of Migration, I set the default project to the API and I got the same error, but the answer: I just set the API project as the startup project and tried again. The issue was gone.

Have fun. Shahab Attarnejad

Can you change .csproj to add RunCommand like below:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <Prefer32Bit>false</Prefer32Bit>
    <PlatformTarget>x86</PlatformTarget>
    <Optimize>false</Optimize>
    <RunCommand Condition="'$(PlatformTarget)' == 'x86'">$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand>
    <RunCommand Condition="'$(PlatformTarget)' == 'x64'">$(ProgramW6432)\dotnet\dotnet</RunCommand>
  </PropertyGroup>

</Project>

Maybe you need to add 2 line of RunCommand and update the correct path of dotnet on your laptop.

This issue happens when you are on windows 64bit and run x86 application.

I had a .Net Core console app built and deployed.

The project's Platform target is x86.

Target framework is .Net Core 2.2(x86).

Although .Net Core 2.2 (x86) SDK is installed, I get following error after executing the command dotnet myapp.dll in Developer Command Prompt VS2017.

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 versions are installed:
2.0.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

The .Net Core 2.2(x86) SDK was installed under path "C:\\Program Files (x86)\\dotnet\\shared", and System Environment Variables contains "C:\\Program Files (x86)\\dotnet\\".

Any suggestion? Thanks!

~~~Update1

Following are part of .csproj info, sorry can't show whole thing.

 <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp2.2</TargetFramework> <Platforms>AnyCPU;x86;x64</Platforms> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <PlatformTarget>x86</PlatformTarget> <Prefer32Bit>true</Prefer32Bit> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PlatformTarget>x64</PlatformTarget> <Prefer32Bit>true</Prefer32Bit> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'"> <PlatformTarget>x86</PlatformTarget> </PropertyGroup>

For me, I just verified that all the projects in the solution is of same Target framework version. Once that was done, the issue was fixed.

You could view the Target framework version by right clicking a project (*.csproj) and go to properties. 在此处输入图像描述

When I got this error just now, it turned out that I need to run an update on Visual Studio.

Close your project window, open the Visual Studio Installer , and run the update.

If you have this issue in 2022. @Khai Nguyen answer worked for me.

HelloWorld.csproj

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp6.0</TargetFramework>
    <ImplicitUsings>disable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

I changed the <TargetFramework>netcoreapp5.0</TargetFramework>

to

<TargetFramework>netcoreapp6.0</TargetFramework>

Since, 6.0 was already installed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM