Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在我的.Net Core 2.0项目中,使用了.Net FW包而不是.Net标准(警告NU1701)_C#_.net_Nuget_.net Core - Fatal编程技术网

C# 在我的.Net Core 2.0项目中,使用了.Net FW包而不是.Net标准(警告NU1701)

C# 在我的.Net Core 2.0项目中,使用了.Net FW包而不是.Net标准(警告NU1701),c#,.net,nuget,.net-core,C#,.net,Nuget,.net Core,我在我的.NETCore1.0项目中使用了nuget软件包,该软件包运行起来没有任何问题(该软件包使用了.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'

我在我的.NETCore1.0项目中使用了nuget软件包,该软件包运行起来没有任何问题(该软件包使用了.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标准1.1版本可用。我知道在.Net Core 2.0中这是可能的,但我也知道由于兼容性的原因,这并不总是可行的,那么,为什么nuget不直接使用实际工作的.Net标准1.1版本,我如何强制使用它来消除警告呢?

看起来这非常特定于依赖包的版本
SQLitePCLRaw.lib.esqlite3.*
,它们是.Net Core/.Net标准的可传递依赖项
SQLitePCLRaw.bundle_green
/
sqlite net pcl
。这可能也是特定于这些软件包的
1.1.5
版本的,因为最新版本(
1.1.8
)的编写方式不同,以表示支持的平台-
1.1.5
软件包不包含
lib
文件夹,只有
运行时
文件夹,没有依赖项组,因此NuGet对支持的框架感到困惑,并假定该包是为.NET Framework编写的。较新的版本解决了这个问题,它有一个
lib
文件夹,其中包含一个虚拟
.\u
文件的受支持框架的子文件夹

如果要确保依赖关系图中只有明确支持.NET标准或.NET核心的包(无论项目目标是什么),可以将其添加到项目文件中:

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

真的

你太棒了,非常感谢,csproj解决了这个问题:)