[英]For a .Net Core 2.1 project, Why does Nuget restores .Net 4.6.1 packages?
If a package is not available for .Net Core how do we enforce strict .Net runtime version checking during, Install-Package
command? 如果.Net Core没有软件包,我们如何在
Install-Package
命令期间强制执行严格的.Net运行时版本检查?
Install-package command, why does Visual Studio even, restores .Net 4.6.1 version, just to give a runtime error at later stages!
Install-package命令,为什么Visual Studio甚至还原.Net 4.6.1版本,只是为了在后期阶段给出运行时错误!
I'm sure VS team has thought about it and there must be a reason! 我确信VS团队已经考虑过了,必须有理由! As well as a mechanism to validate & strict runtime version checking during Install-Package.
以及在Install-Package期间验证和严格运行时版本检查的机制。
Warnings: 警告:
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'.
警告NU1701软件包'Microsoft.AspNet.Identity.Core 2.2.2'使用'.NETFramework,Version = v4.6.1'而不是项目目标框架'.NETStandard,Version = v2.0'进行了恢复。 This package may not be fully compatible with your project.
此软件包可能与您的项目不完全兼容。
Edit: I just took one of the full .net framework packages, as example. 编辑:我刚刚使用了一个完整的.net框架包,例如。
Intention was to ask how to prevent it from happening in Nuget package manager. 意图是询问如何防止它在Nuget包管理器中发生。
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'.警告NU1701包
<any full .net framework package>
使用'.NETFramework,Version = v4.6.1'而不是项目目标框架'.NETStandard,Version = v2.0'进行了恢复。 This package may not be fully compatible with your project.此软件包可能与您的项目不完全兼容。
It's explained by Microsoft in this GitHub issue . 微软在这个GitHub问题中对此进行了解释。 Quoting the relevant part:
引用相关部分:
[...]
[...]
Whenever you use NuGet packages that go through the compat shim you'll get a warning like this:
每当你使用通过compat shim的NuGet包时,你会收到如下警告:
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'.
警告NU1701:使用'.NETFramework,Version = v4.6.1'而不是项目目标框架'.NETCoreApp,Version = v2.0'恢复包'Huitian.PowerCollections 1.0.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.
我们确保每次构建时都会收到此警告(仅在程序包恢复期间),以确保您不会意外忽略它。
The idea here is that we have no way of knowing whether the .NET Framework binary will actually work.
这里的想法是我们无法知道.NET Framework二进制文件是否真正起作用。 For example, it might depend on WinForms.
例如,它可能依赖于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.
如果没有,您将不得不使用不同的包或等待包支持您的目标框架。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.