For a .Net Core 2.1 project, Why does Nuget restores .Net 4.6.1 packages?

前端 未结 1 848
长情又很酷
长情又很酷 2021-02-13 17:06

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

相关标签:
1条回答
  • 2021-02-13 17:39

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

    [...]

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

    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.

    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.

    0 讨论(0)
提交回复
热议问题