简体   繁体   中英

In my .Net Core 2.0 project, .Net FW package is used instead of .Net Standard (warning NU1701)

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM