0

I am trying to convert some code to .NET CORE 2.0, but, as I'm nuget restore-ing, I get a lot of NU1701 warnings, saying that some packages were restored using .NET461. Funny thing, is I don't reference these packages. How can I find out which N-level dependency actually references these packages?

And it's ancient versions of the packages as well, so it is definitely some third-party dependency. I would never reference these versions of the packages. Any tips on how I can find where the dependency stems from?

Examples:

NU1701: Package 'Microsoft.AspNet.WebApi.Client 4.0.20710' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Microsoft.AspNet.WebApi.Core 4.0.20710' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Microsoft.AspNet.WebApi.Client 4.0.20710' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Microsoft.AspNet.WebApi.Core 4.0.20710' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Microsoft.AspNet.WebApi.WebHost 4.0.20710' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Microsoft.AspNet.WebApi.WebHost 4.0.20710' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Microsoft.Net.Http 2.0.20710' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Microsoft.Net.Http 2.0.20710' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Microsoft.Web.Infrastructure 1.0.0' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Microsoft.Web.Infrastructure 1.0.0' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Swashbuckle.Core 5.6.0' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'Swashbuckle.Core 5.6.0' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'WebActivatorEx 2.0.0' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
NU1701: Package 'WebActivatorEx 2.0.0' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETCoreApp,Version=v2.0'. This may cause compatibility problems.
Erik A. Brandstadmoen
  • 10,430
  • 2
  • 37
  • 55
  • I posted an msbuild target to help list dependencies at https://stackoverflow.com/questions/44944172/net-core-dependency-tree/44944566#44944566, maybe the second one of those can help – Martin Ullrich Nov 20 '17 at 15:26
  • 2
    Though I'm pretty confident you're directly referencing `Swashbuckle` which doesn't work on .net core (there is a different swashbuckle package for asp.net core) – Martin Ullrich Nov 20 '17 at 15:28
  • You are correct. Swashbuckle was the devil in the details (see my answer below). Switched to Swashbuckle.AspNetCore. :) – Erik A. Brandstadmoen Nov 20 '17 at 15:32

1 Answers1

3

Found a solution:

  1. Pipe the nuget restore to a log
  2. Select-string project.assets.json from the log.
  3. Run Select-String Microsoft.AspNet.WebApi.Core on each of the project.assets.json
  4. Open the matching ones in an editor. See what dependency depended on Microsoft.Aspnet.WebApi.Core (e.g.)

In my case, it was Swashbuckle, which was in a .NET full framework version. Switched to Swachbuckle.AspNetCore, and the dependencies disappeared.

Erik A. Brandstadmoen
  • 10,430
  • 2
  • 37
  • 55