dotnet restore warning NU1701
Solution 1
You don't necessarily have to wait until PusherClient is upgraded for .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
- for a specific package
<PackageReference Include="Contoso.Base.API" Version="1.0.3"> <NoWarn>NU1701</NoWarn> </PackageReference>
- for all packages
<NoWarn>NU1701</NoWarn>
See scenarios 2 and 3 in NuGet wiki for ways to do it from GUI.
It is possible, though, that your 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).
-
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>
Solution 2
As a side note, don't do this:
<PropertyGroup>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>
Doing that will break any other NoWarn settings being picked up elsewhere, such as from a directory.build.prop file. Instead, do this:
<PropertyGroup>
<NoWarn>$(NoWarn);NU1701</NoWarn>
</PropertyGroup>
That way, any global settings are preserved.
Solution 3
For .NET Core 1.x:
You need to tell the guys from PusherClient to make their project .NET-Core ready.
Solution 4
As Yair pointed out, there is an open issue around this subject on GitHub: github.com/NuGet/Home/issues/5740.
Where the dependency being resolved with a fallback framework version is transitive, suppressing the warning for the referenced package will not work.
For example, Microsoft.TeamFoundationServer.ExtendedClient is dependent on Microsoft.AspNet.WebApi.Core which isn't compatible with .NET Core 3.0, resulting in the warning. Adding NoWarn to Microsoft.TeamFoundationServer.ExtendedClient won't work.
As a workaround (You can see my post here: Workaround On GitHub Issue), you can directly reference the transitive dependency and use NoWarn against that package.
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.3" NoWarn="NU1701" />
<PackageReference Include="Microsoft.TeamFoundationServer.ExtendedClient" Version="16.153.0"/>
</ItemGroup>
Related videos on Youtube
Comments
-
fluter over 3 years
I am using .NET Core with C#, and when I did
dotnet restore
, it gave the following error:PS C:\workspace\Arbitrator> dotnet restore
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.
This package in problem is PusherClient. I just followed the NuGet documents to import it. How can I fix this warning?
-
fluter almost 7 yearsWhat makes the library not .NET-Core ready? It's already in nuget.org, so I thinks it's OK to use it?
-
svick almost 7 years@fluter PusherClient is a .Net Framework library. To use it on .Net Core 1.x, it would need to be changed to a .Net Standard 1.x library.
-
Sourcerer almost 7 years@fluter But according to MS it is a new feature of the 2.0 version of .NET Core that you can reference .NET Framework 4.6.1 (and below) libraries.
-
mateuszlewko over 6 yearsIs it possible to suppress such warning?
-
Nick over 6 yearsYes, put <PropertyGroup><NoWarn>NU1701</NoWarn></PropertyGroup> in your csproj
-
yair over 5 yearsCan't see a way to suppress the warning per
PackageReference
in the.csproj
file. I did find an open issue on this very subject: github.com/NuGet/Home/issues/5740 . Cast your vote :) -
Syroot about 5 yearsThat should be fine for being inside a
<PackageReference>
though, shouldn't it? -
Chris M. about 5 yearsThat really depends. My solution, which is fairly large, makes extensive use of the Directory.Build.Props file to set common settings across all the projects. One of those settings is a list of warnings to supress. In this case w/o the $(NoWarn) this project overrides that list and just has the single NU1707 supression.