0

I am creating a new web API in .Net core 5.0. However, every time I try to build it, I get the following error:

Package HotChocolate.AspNetCore 11.1.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package HotChocolate.AspNetCore 11.1.0 supports: net5.0 (.NETCoreApp,Version=v5.0)

The target framework for my app is net5.0:

<PropertyGroup>
  <TargetFramework>net5.0</TargetFramework>
</PropertyGroup>


Installed .Net Version: 5.0.202
OS: Manjaro KDE 21.21.0.2
Kernel version: linux 5.10.30-1
IDE: JetBrains Rider 2020.3

For some reason build tool is interpreting the target framework as .NetFramework v5.0 instead of .NetCore v5.0 .Can anyone please let me know what is happening here?

Mahesh Nepal
  • 1,385
  • 11
  • 16
  • Are you using the `dotnet build` command? – Nishan May 05 '21 at 16:54
  • From the [HotChocolate.AspNetCore repository](https://www.nuget.org/packages/HotChocolate.AspNetCore/), we can see that the HotChocolate.AspNetCore 11.1.0 support Asp.net Core 5.0, and I also try to install this version of package in my application, it works well. So, the issue might relate the Nuget cache, try to use `dotnet nuget locals all --clear` to clear the cache. then, rebuild the application. Besides, if you are using Visual studio 2019 to create your application, please make sure you are using Visual Studio 2019 16.8 or later. – Zhi Lv May 06 '21 at 05:48
  • @ZhiLv, Unfortunately, clearing local nuget cache did not help. And also this happens for all the libraries that target `.net core` and `.net standard` not only `HotChocolate`. – Mahesh Nepal May 06 '21 at 07:26
  • @NishānWickramarathna Yes, I am using `dotnet build` command – Mahesh Nepal May 20 '21 at 06:26

2 Answers2

0

This could be due to an old version of Nuget. Try removing and reinstalling Nuget.

Removing:

pamac remove nuget
pacman -R nuget

Installing:

pamac install nuget
pacman -S nuget
Nishan
  • 3,644
  • 1
  • 32
  • 41
0

I had the exact same error message when first trying to get hot chocolate working for me. When I looked at the project->properties->Target framework I noticed that .net 5.0 wasn't in the list.

Instead of downloading dotnet 5.0 separately, I updated my visual studio and after rebooting visual studio had 5.0 framework available and everything automagically fixed itself. You could also run a dotnet restore on your package manager console.

  • I am actually using Rider IDE and the target framework is listed in the list. Additionally, I have no problem building the project from rider. It's the dotnet CLI that is giving me the trouble. The dotnet version I installed is `5.0.202` – Mahesh Nepal May 20 '21 at 06:24