.netnugetvisual-studio-2017compatibility.net-core-2.0

How to hide .NET Core compatibility warnings when referencing .NET 4.6 NuGet package in VS 2017.3


I'm working on a .NET Core CLI app that needs to reference a 3rd party NuGet package that has not been published with a netcoreappX.X target. I've run the Analyze Project Portability tool on it and got 100% compatibility, which is expected, as this is a relatively simple library.

The problem then comes in the form of this annoying NuGet warning:

Warning: NU1701
Package 'XXXXXX 1.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.

Is there a way to hide this warning for a specific NuGet package?


Solution

  • I found an answer to my question in a Google Images search, which led me to this seemingly unrelated SO post:

    Suppressing issues from Roslyn code Analyzers

    In short, the Properties page of the NuGet package reference has a NoWarn attribute where the error code can be specified, as shown in the following image:

    enter image description here