dotnet恢复警告NU1701

编程入门 行业动态 更新时间:2024-10-26 05:20:04
本文介绍了dotnet恢复警告NU1701的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在将C#与.NETCore一起使用,当我执行 dotnet恢复时,出现以下错误:

I am using .NETCore with C# and when I did dotnet restore it gave the following error:

PS C:\workspace\Arbitrator> dotnet恢复

PS C:\workspace\Arbitrator> dotnet restore

C:\workspace\Arbitrator\Arbitrator.csproj:警告NU1701 :使用 .NETFramework,Version = v4.6.1而不是项目目标框架 .NETCoreApp,Version = v2.0恢复了软件包 PusherClient 0.5.0。这可能会导致兼容性问题。 C:\workspace\Arbitrator\Arbitrator.csproj:警告NU1701:使用'.NETFramework,Version = v4.6.1'代替了项目目标框架'.NETCoreApp,恢复了'WebSocket4Net 0.14.1'软件包,版本= v2.0。这可能会导致兼容性问题。

C:\workspace\Arbitrator\Arbitrator.csproj : warning NU1701: Package 'PusherClient 0.5.0' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems. C:\workspace\Arbitrator\Arbitrator.csproj : warning NU1701: Package 'WebSocket4Net 0.14.1' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.

有问题的软件包为 PusherClient ,我只是按照掘金文件将其导入,如何解决此警告?

This package in problem is PusherClient, I just followed the nugget documents to import it, how can I fix this warning?

推荐答案

您不必等到 PusherClient 升级为.NET Core。

You don't necessarily have to wait until PusherClient is upgraded for .NET Core.

引用.NET .NET Core的Framework 4.6.1(及以下)是新功能自.NET Core / Standard 2.0预览版2 / VS 2017预览版15.3和根据MS ,它可以被认为是一项功能,可以帮助您将.NET Framework代码随时间迁移到.NET Standard或.NET Core 。

Referencing .NET Framework 4.6.1 (and below) from .NET Core is a new feature available since .NET Core/Standard 2.0 preview 2 / VS 2017 preview 15.3 and according to MS it can be thought of as a feature that helps you migrate .NET Framework code to .NET Standard or .NET Core over time.

  • 您可以禁止显示该警告

  • You can just suppress this warning

    • fo ra特定软件包

    <PackageReference Include="Contoso.Base.API" Version="1.0.3"> <NoWarn>NU1701</NoWarn> </PackageReference>

    • 所有套餐
    • <NoWarn>NU1701</NoWarn>

      请参阅NuGet Wiki中的场景2和3,了解如何从GUI进行操作。

      但是,当您调用.NET Core不支持的的API(例如WPF中的某些功能)时,应用程序可能会在运行时中失败。失败的另一个原因可能是 PusherClient 可能使用的本机API 。因此,您应该对其进行广泛的测试。 但在大多数情况下,它将仅在支持.NET Core 的所有平台上运行(例如,我已经测试了具有 MathNet.Numerics 依赖项的应用程序即使 MathNet.Numerics 也是.NET Framework 4.6.1),它也可以在Linux上运行。

      It is possible, though, that you application may fail in run-time when you call an API (like something from WPF) that is not supported by .NET Core. Another reason of a failure could be native APIs possibly used by PusherClient. So you should test it extensively. But in most cases it will just work on all platforms where .NET Core is supported (for example, I have tested an application with MathNet.Numerics dependency and it worked on Linux even though MathNet.Numerics is also .NET Framework 4.6.1).

      如果您不需要跨平台的应用程序,只需在csproj文件中添加以下内容即可将其目标框架更改为.NET 4.6.1:

      If you don't need your app to be cross-platform just change its target framework to .NET 4.6.1 by adding the following to your csproj file:

      <TargetFramework>net461</TargetFramework>

  • 更多推荐

    dotnet恢复警告NU1701

    本文发布于:2023-11-16 09:47:44,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1603175.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:dotnet

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!