dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.38k stars 10k forks source link

Package Microsoft.IdentityModel.Protocols.OpenIdConnect 6.7.1 is not compatible with net5 #28045

Closed mohabbati closed 3 years ago

mohabbati commented 3 years ago

Error NU1202 Package Microsoft.IdentityModel.Protocols.OpenIdConnect 6.7.1 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Package Microsoft.IdentityModel.Protocols.OpenIdConnect 6.7.1 does not support any target frameworks.

Tratcher commented 3 years ago

That package has a netstandard2.0 target which should be net5.0 compatible. Are you updating your project from an old version (netcoreapp3.1), or creating a new project? I don't get this error with a new 5.0 console app or web app.

mohabbati commented 3 years ago

I created a new webapi app on net5 and get the error when building. I enabled OpenApi support. I try it again, create a new project and get the error again.

Pilchie commented 3 years ago

@mohabbati are you building in Visual Studio, or with dotnet build? What VS version do you have and what .NET Core SDK. Finally, are you using nuget.exe to restore? If so, what version of nuget.exe are you using?

mohabbati commented 3 years ago

@Pilchie I used visual studio 16.8.2 and .net core sdk 5.0.1. I didn't add from nuget. the vs added the packages when I checked to enable OpenApi support when creating an asp .net core web api project.

Tratcher commented 3 years ago

Are you actually using auth? There's a related issue about the auth packages being installed for a few templates that don't need them. https://github.com/dotnet/aspnetcore/issues/27105. If you're not using these two packages you can remove them.

    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" NoWarn="NU1605" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.0" NoWarn="NU1605" />

I wasn't able to reproduce the NU1202 error on 16.8.0 or 16.8.2. I do get the extra package references though.

mohabbati commented 3 years ago

The issue is that, i dont add any package myself. the packages automatically add by VS when I enable openapi support. i check it several times, however I want to check on another machine. can you create a webapi project and enable "OpenApi Support" check box?

Tratcher commented 3 years ago

I was using the WebApi project with the "OpenApi Support" check box.

I know the packages don't belong there, #27105 is tracking that. You should be able to remove them from your project.

wiwichu commented 3 years ago

If I use Nuget "Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.0" with .Net 5.0 blazor webassembly I get the following error on clean: NETSDK1082 There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.

I created a brand new blazor webassembly .Net 5.0 project. The issue occurs when I include an openidconnect reference, but disappears if I delete that reference.

net5.0
Tratcher commented 3 years ago

@wiwichu see https://github.com/dotnet/aspnetcore/issues/28362.

ghost commented 3 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.