对于 .Net Core 2.1 项目,为什么 Nuget 会还原 .Net 4.6.1 包? [英] For a .Net Core 2.1 project, Why does Nuget restores .Net 4.6.1 packages?

查看:24
本文介绍了对于 .Net Core 2.1 项目,为什么 Nuget 会还原 .Net 4.6.1 包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果包不可用于 .Net Core 我们如何在 Install-Package 命令期间强制执行严格的 .Net 运行时版本检查?

If a package is not available for .Net Core how do we enforce strict .Net runtime version checking during, Install-Package command?

Install-package 命令,为什么 Visual Studio 甚至,恢复 .Net4.6.1版本,只是为了后期给出运行错误!

Install-package command, why does Visual Studio even, restores .Net 4.6.1 version, just to give a runtime error at later stages!

我相信VS团队已经考虑过了,肯定是有原因的!以及验证 & 的机制安装包期间严格的运行时版本检查.

I'm sure VS team has thought about it and there must be a reason! As well as a mechanism to validate & strict runtime version checking during Install-Package.

警告:

警告 NU1701 包Microsoft.AspNet.Identity.Core 2.2.2"是使用 '.NETFramework,Version=v4.6.1' 而不是项目恢复目标框架.NETStandard,Version=v2.0".这个包可能不是与您的项目完全兼容.

Warning NU1701 Package 'Microsoft.AspNet.Identity.Core 2.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.

我只是以完整的 .net 框架包之一为例.

I just took one of the full .net framework packages, as example.

意图是询问如何防止它在 Nuget 包管理器中发生.

Intention was to ask how to prevent it from happening in Nuget package manager.

警告 NU1701 包 <任何完整的 .net 框架包> 是使用 '.NETFramework,Version=v4.6.1' 而不是项目恢复目标框架.NETStandard,Version=v2.0".这个包可能不是与您的项目完全兼容.

Warning NU1701 Package <any full .net framework package> was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.

推荐答案

微软在 这个 GitHub 问题.引用相关部分:

It's explained by Microsoft in this GitHub issue. Quoting the relevant part:

[...]

每当您使用通过兼容垫片的 NuGet 包时,您都会收到如下警告:

Whenever you use NuGet packages that go through the compat shim you'll get a warning like this:

警告 NU1701:使用.NETFramework,Version=v4.6.1"而不是项目目标框架.NETCoreApp,Version=v2.0"恢复了包Huitian.PowerCollections 1.0.0".此软件包可能与您的项目不完全兼容.

Warning NU1701: Package 'Huitian.PowerCollections 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.

我们确保您在每次构建时(而仅在包恢复期间)都会收到此警告,以确保您不会意外忽略它.

We've made sure you get this warning every time you build (rather only during package restore) to ensure you don't accidentally overlook it.

这里的想法是我们无法知道 .NET Framework 二进制文件是否真的可以工作.例如,它可能依赖于 WinForms.为确保您不会浪费时间对无法正常工作的问题进行故障排除,我们让您知道您可能会出轨.当然,您必须忽略的警告很烦人.因此,我们建议您测试您的应用程序/库,如果您确信一切正常,您可以取消警告:

The idea here is that we have no way of knowing whether the .NET Framework binary will actually work. For example, it might depend on WinForms. To make sure you don't waste your time troubleshooting something that cannot work, we let you know that you're potentially going off the rails. Of course, warnings you have to overlook are annoying. Thus, we recommend that you test your application/library and if you're convinced everything is working fine, you suppress the warning:

[...]

因此,如果该软件包有效,那么您可以取消警告.如果没有,您将不得不使用不同的包或等待该包支持您的目标框架.

So if the package works, then you can suppress the warning. If it doesn't, you'll have to use a different package or wait for the package to support your target framework.

这篇关于对于 .Net Core 2.1 项目,为什么 Nuget 会还原 .Net 4.6.1 包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆