Misza
Misza

Reputation: 78

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

Upvotes: 4

Views: 14315

Answers (1)

Leo Liu
Leo Liu

Reputation: 76660

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.

Upvotes: 3

Related Questions