简体   繁体   English

对于.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?

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.

相关问题 在NET Standard项目中消耗.NET 4.6.1 NuGet软件包的问题(bin中缺少dll) - Problem consuming .NET 4.6.1 NuGet packages in NET Standard project ( missing dlls in bin ) 如何在基于 .NET Framework 4.6.1 构建的单元测试项目中添加 .NET Core 2.1 项目引用 - How to add .NET Core 2.1 project reference in Unit Test project built on .NET Framework 4.6.1 为什么 SetBasePath 在 .NET Core 3.1 中不起作用? 我试过添加 nuget 包,但它不起作用 - Why does SetBasePath not work in .NET Core 3.1? I've tried adding nuget packages, but it doesn't work 为什么.NET Core 2.0的性能比.NET Framework 4.6.1差 - Why does .NET Core 2.0 perform worse than .NET Framework 4.6.1 如果已经安装了SDK,为什么需要使用nuget将ASP.NET Core软件包添加到项目中? - Why do I need to use nuget to add ASP.NET Core packages into my project if I already have the SDK installed? .NET标准库能否以某种方式使用支持.NET Framework 4.6.1的nuget包 - Can .NET standard libraries somehow consume nuget packages, which support .NET Framework 4.6.1 .net核心中的Azure ServiceBus消息未在.net 4.6.1中解析 - Azure ServiceBus message from .net core does not parse in .net 4.6.1 我的 NuGet 包是否与 .NET Core 兼容? - Are my NuGet packages compatible with .NET Core? 搜索.NET Core或标准NuGet包 - Search for .NET Core or Standard NuGet packages 严格创建用于组成NuGet包的.Net项目 - Create a .Net project strictly for composition of NuGet packages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM