Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget restore fails (NU1201) for .NET Standard referencing .NET Framework

I've been googling around a while, but failed to find a proper answer.

My project contains two libraries:

LibA - .NET standard 2.0

LibB - .NET Framework 4.7, which contains some nuget package

I'm referencing (via Project ref) LibB from LibA (i.e. my goal is to use LibB from LibA). Everything works well if LibB uses packages.config file, but nuget restore fails once I turn to package references in LibB csproj. It gives NU1201, saying that

Project LibB is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project LibB supports: net47 (.NETFramework,Version=v4.7)

Is there any known workaround or this is a VS bug or it just works as designed (I've heard packages.config way skips compatibility check during restore).

like image 409
Misza Avatar asked Oct 29 '25 01:10

Misza


1 Answers

Nuget restore fails (NU1201) for .NET Standard referencing .NET Framework

Yes, it just works as designed. There is an issue for NuGet restore when you using new SDK-based project type or PackageReference in the .net framework.

https://github.com/NuGet/Home/issues/5461

https://github.com/dotnet/sdk/issues/1755

When we use packages.config projects or non-SDK based project type, NuGet do not check compatibility during restore.

So, to resolve this issue, make sure the referenced project is an old style csproj or use packages.config.

Hope this helps.

like image 117
Leo Liu-MSFT Avatar answered Oct 30 '25 15:10

Leo Liu-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!