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?
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.