We are getting weird error messages during our build.
They don't make any sense, because they are wrong (see MS documentation):
Error NU1202: Package XY 1.0.0 is not compatible with net48 (.NETFramework,Version=v4.8). Package XY 1.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
Error NU1201: Package XY 1.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package XY 1.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
and the weirdest one:
Error NU1201: Package XY 1.0.0 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package XY 1.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
What is causing this behavior?
In our case, this was caused by referencing the same project once as a package and once as a project.
It happened transitively:
Solutions:
It's unfortunate, that Microsoft does not log a better error message, because it took us quite some time to find out what exactly the problem is.