1

I created a ASP.NET Core web application. In this solution I also have a .NET Standard 2.0 project.

First I added a reference from .NET Standard project to a dll (.NET framework 4.6.1) manually without any issues and it works fine. I have then created a Nuget package for .NET framework dll, and tried to install this package in .NET Standard project.

I got an error

Package xxx was restored using .net framework, version = 4.6.1. instead of project target framework '.NET standard, version = v2.0'. This package may not be fully compatible with your project.

I am confused, how come i can use a .net framework assembly when referenced manually, and when it is installed via nuget i receive this error.

Further more, when i install this nuget in .NET Core 2.1. project (same solution) i get the same error.

2
  • A .NET Standard project should never use a reference of .NET Framework, blog.lextudio.com/… If you made a mistake in the beginning, then any following issues are expected. Commented Nov 3, 2018 at 22:48
  • ad "should never use a reference of .NET Framework": I'd suggest testing the dll for possibly incompatible API usage using ApiPort. If this looks good the dll should be fine to use. But if this is a project you are developing, I suggest moving it to .NET Standard or multi-target to both Framework and Standard. But for third-party dlls that you package up this may be the only way. Commented Nov 4, 2018 at 19:45

1 Answer 1

1

This warning is specific to NuGet. When manually adding a dll, no part in the build checks the target framework of that dll (in theory, most dll files should carry a TargetFrameworkAttribute assembly metadata but it isn't required) and you are responsible for making sure that you are using a compatible assembly.

To silence this NuGet warning (and accepting that there may be issues at run-time when using a package originally authored for .NET Framework), you can add this NoWarn metadata to your package reference:

<PackageReference Include="My.Package" Version="1.2.3" NoWarn="NU1603" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.