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.
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" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.