在我的.Net Core 2.0项目中,使用.Net FW包而不是.Net Standard(警告NU1701)(In my .Net Core 2.0 project, .Net FW packag

系统教程 行业动态 更新时间:2024-06-14 17:03:54
在我的.Net Core 2.0项目中,使用.Net FW包而不是.Net Standard(警告NU1701)(In my .Net Core 2.0 project, .Net FW package is used instead of .Net Standard (warning NU1701))

我在我的.Net Core 1.0项目中使用了nuget软件包sqlite-net-pcl ,该项目没有任何问题(使用.Net标准1.1版本的软件包)。 现在,我将这个项目升级到了.Net Core 2.0,并且突然间我收到了这些构建警告:

1>C:\Projects\Project.csproj : warning NU1701: Package 'SQLitePCLRaw.lib.e_sqlite3.linux 1.1.5' 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. 1>C:\Projects\Project.csproj : warning NU1701: Package 'SQLitePCLRaw.lib.e_sqlite3.osx 1.1.5' 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. 1>C:\Projects\Project.csproj : warning NU1701: Package 'SQLitePCLRaw.lib.e_sqlite3.v110_xp 1.1.5' 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.

很明显,我的.Net Core 2.0项目现在使用nuget包的.Net Framework 4.6.1版本,即使有.Net Standard 1.1版本可用。 我知道使用.Net Core 2.0这是可能的,但我也知道这并不总是工作,因为兼容性的原因,所以为什么不nuget只使用。净标准1.1版本,这将实际工作,我怎样才能强迫消除警告?

I was using the nuget package sqlite-net-pcl in my .Net Core 1.0 project which was working without any problems (the .Net Standard 1.1 version was used of the package). Now, I upgraded this project to .Net Core 2.0 and suddenly I'm getting these build warnings:

1>C:\Projects\Project.csproj : warning NU1701: Package 'SQLitePCLRaw.lib.e_sqlite3.linux 1.1.5' 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. 1>C:\Projects\Project.csproj : warning NU1701: Package 'SQLitePCLRaw.lib.e_sqlite3.osx 1.1.5' 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. 1>C:\Projects\Project.csproj : warning NU1701: Package 'SQLitePCLRaw.lib.e_sqlite3.v110_xp 1.1.5' 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.

Obviously, my .Net Core 2.0 project is now using the .Net Framework 4.6.1 version of the nuget package, even if there's a .Net Standard 1.1 version available. I know that with .Net Core 2.0 this is possible, but I also know that this doesn't always work because of compatibility reasons, so why doesn't nuget just use the .Net Standard 1.1 versions which will actually work and how can I force that to eliminate the warnings?

最满意答案

它看起来像是特定于SQLitePCLRaw.lib.esqlite3.*版本的依赖包,它们是SQLitePCLRaw.bundle_green / sqlite-net-pcl的.NET Core / .NET标准片的传递依赖。 这可能也是特定于1.1.5版本的这些软件包,因为最新版本( 1.1.8 )的创作方式不同,以指示支持的平台 - 1.1.5软件包不包含lib文件夹,仅包含runtimes文件夹和没有依赖关系组,因此NuGet对支持的框架感到困惑,并假定该软件包是为.NET Framework创作的。 新版本通过为包含虚拟_._文件的受支持框架提供一个带有子文件夹的lib文件夹来解决此问题。

如果你想确保你的依赖关系图中只包含明确支持.NET Standard或.NET Core的包(不管你的项目目标是什么),你可以将它添加到你的项目文件中:

<PropertyGroup> <DisableImplicitAssetTargetFallback>true</DisableImplicitAssetTargetFallback> </PropertyGroup>

It looks like this is very specific to the versions of dependent packages SQLitePCLRaw.lib.esqlite3.* which are transitive dependencies of the .NET Core / .NET Standard slices of SQLitePCLRaw.bundle_green / sqlite-net-pcl. This probably is also specific to the 1.1.5 version of these packages, since the latest versions (1.1.8) are authored differently to indicate supported platforms - the 1.1.5 packages don't contain a lib folder, only a runtimes folder and no dependency groups so NuGet is confused about the supported frameworks and assumes the package was authored for .NET Framework. The newer versions solve this by having a lib folder with subfolders for the supported frameworks containing a dummy _._ file.

If you want to ensure you only have packages in your dependency graph that explicitly support .NET Standard or .NET Core (whatever your project targets), you can add this to your project file:

<PropertyGroup> <DisableImplicitAssetTargetFallback>true</DisableImplicitAssetTargetFallback> </PropertyGroup>

更多推荐

本文发布于:2023-04-24 14:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/fd099998a48a49fec9d9bedcab015c83.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不是   项目   FW   Net   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!