简体   繁体   中英

Why Netcoreapp3.1 not Compatible with net5.0 Class Library

As per my understanding, net5.0 is compatible with both netcoreapp and older .net versions.

I am trying to create an Azure function that targets.netcoreapp3.1 and use a library that was built targetting.net5.0. However, I am getting the following error, which indicates there is incompatibility issues.

Error NU1202 Package XXX is not compatible with.netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package XXX supports:.net5.0 (.NETCoreApp,Version=v5.0)

I have quoted the above from VS 2019 but replaced package name with XXX for privacy. The two strings in bracket are verbatim and I am not clear why net5.0 is being listed as .NETCoreApp, Version 5.0 .

Could someone explain what is going on and if there is anything I have misunderstood?

As per my understanding,.net5.0 is compatible with both.netcoreapp and older .net versions.

Yes, but not the other way round. There are things in .NET 5.0 which aren't in .NET Core 3.1.

You can target a framework for an application and then use a library targeting an earlier framework, but not the other way round. So for example, it would be fine for your Azure function to target .NET 6.0 and use a library targeted at .NET 5.0.

Basically, to solve your problem you'll either need to use a different library (or an earlier version of the library which targeted .NET Core 3.1, or maybe .NET Standard) or update to a more recent runtime.

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