在VS 2017.3中引用.NET 4.6 NuGet程序包时如何隐藏.NET Core兼容性警告 [英] How to hide .NET Core compatibility warnings when referencing .NET 4.6 NuGet package in VS 2017.3
问题描述
我正在使用一个.NET Core CLI应用程序,该应用程序需要引用一个第三方发布的NuGet程序包,该程序包尚未以 netcoreappX.X
目标发布。我已经在其上运行分析项目可移植性工具,并获得了 100%兼容性,这是可以预期的,因为这是一个相对简单的库。
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.
然后问题以这种令人讨厌的NuGet警告的形式出现:
The problem then comes in the form of this annoying NuGet warning:
警告:NU1701
使用 .NETFramework,Version = v4.6.1而不是项目目标框架 .NETCoreApp,Version = v2.0还原了软件包 XXXXXX 1.0.0。该软件包可能与您的项目不完全兼容。
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.
是否可以针对特定的NuGet软件包隐藏此警告?
Is there a way to hide this warning for a specific NuGet package?
推荐答案
我在Google图片搜索中找到了我的问题的答案,这导致我看到了一条看似无关的SO帖子:
I found an answer to my question in a Google Images search, which led me to this seemingly unrelated SO post:
简而言之,NuGet包引用的属性页面具有 NoWarn 属性,可以在其中指定错误代码,如下图所示:
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:
< img src = https://i.stack.imgur.com/qredo.png alt =在此处输入图片描述>
这篇关于在VS 2017.3中引用.NET 4.6 NuGet程序包时如何隐藏.NET Core兼容性警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!