【问题标题】:In my .Net Core 2.0 project, .Net FW package is used instead of .Net Standard (warning NU1701)在我的 .Net Core 2.0 项目中,使用 .Net FW 包而不是 .Net Standard(警告 NU1701)
【发布时间】:2017-10-08 10:44:22
【问题描述】:

我在我的 .Net Core 1.0 项目中使用了 nuget 包 sqlite-net-pcl,该项目运行没有任何问题(使用了该包的 .Net Standard 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 项目现在使用 .Net Framework 4.6.1 版本的 nuget 包,即使有可用的 .Net Standard 1.1 版本。我知道使用 .Net Core 2.0 这是可能的,但我也知道由于兼容性原因这并不总是有效,那么为什么 nuget 不直接使用实际有效的 .Net Standard 1.1 版本,我该如何强制消除警告?

【问题讨论】:

    标签: c# .net nuget .net-core


    【解决方案1】:

    看起来这对于依赖包 SQLitePCLRaw.lib.esqlite3.* 的版本非常具体,它们是 SQLitePCLRaw.bundle_green / sqlite-net-pcl 的 .NET Core / .NET Standard 切片的传递依赖项。这可能也特定于这些包的 1.1.5 版本,因为最新版本 (1.1.8) 的创作方式不同以指示支持的平台 - 1.1.5 包不包含 lib 文件夹,只有 @ 987654328@ 文件夹并且没有依赖组,因此 NuGet 对支持的框架感到困惑,并假定该包是为 .NET Framework 编写的。较新的版本通过使用 lib 文件夹以及包含虚拟 _._ 文件的受支持框架的子文件夹来解决此问题。

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

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

    【讨论】:

    • 你太棒了,非常感谢,csproj的东西解决了它:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-27
    • 1970-01-01
    相关资源
    最近更新 更多