Mike Hawkins
Mike Hawkins

Reputation: 2304

error: Package X 3.0.0 is not compatible with netstandard2.1

I encountered a problem when upgrading my classlib projects to netstandard 2.1.

I have a classlib project with the following .csproj configuration. The project consists of custom functionality built upon net core 3.0 (Previously 2.0) packages.

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

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
  </PropertyGroup>

  <PropertyGroup>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
    <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
    <PackageReference Include="MediatR" Version="7.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0" />
  </ItemGroup>

</Project>

When I run dotnet restore, i receive the following error:

error: Package Microsoft.AspNetCore.Authentication.JwtBearer 3.0.0 is not compatible with netstandard2.1 (.NETStandard,Version=v2.1). Package Microsoft.AspNetCore.Authentication.JwtBearer 3.0.0 supports: netcoreapp3.0 (.NETCoreApp,Version=v3.0)

I have tried to change the TargetFramework property to support both netstandard2.1 and netcoreapp3.0: <TargetFrameworks>netstandard2.1;netcoreapp3.0</TargetFrameworks>

However, i still receive the same error.

What am I missing here?

Upvotes: 0

Views: 3360

Answers (2)

Jerald Siby
Jerald Siby

Reputation: 29

I had a similar problem when I was trying to add the package "microsoft.aspnetcore.authentication.jwtbearer 3.0.0" in VSCode. It threw me an error: Package X 3.0.0 is not compatible with netcore version.

The only thing I did to make it work was to downgrade the jwtbearer package version to a lower one specifically - 2.2.0 It worked!!

Upvotes: 2

Mike Hawkins
Mike Hawkins

Reputation: 2304

I found the solution. I had to target netcoreapp3.0 solely, not netstandard2.1 and netcoreapp3.0.

Upvotes: 0

Related Questions