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?
From the right-click or context menu, select Properties. In the NoWarn box of the package's properties, enter the warning number you want to suppress for this package. If you want to suppress more than one warning, use a comma to separate the warning numbers.
Net Framework will not be part of the . Net Standard, particularly once you get into those areas that have been most heavily refactored by . Net Core (e.g. ASP.Net). You can use this extension for visual studio to check the compatibility.
PrivateAssets is a metadata tag used to control dependency assets. You might be using a dependency purely as a development harness and might not want to expose that to projects that will consume your package. In this scenario, you can use the PrivateAssets metadata to control this behavior.
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:
As of VS2019 (v 16.9.1) you can add the code (or codes, comma separated) to the property Suppress Warnings
, then rebuild the solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With