.net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible

C#.NetTfsasp.net CoreNuget

C# Problem Overview


I have a .net core 2.0 console app. I'm trying to read files from TFS using the following:

https://stackoverflow.com/questions/15346851/how-to-get-a-file-from-tfs-directly-into-memory-i-e-dont-want-to-read-from-f

I head over to nuget and install Microsoft.TeamFoundationServer.ExtendedClient and run into this:

enter image description here

> Package 'Microsoft.AspNet.WebApi.Client 5.2.2' 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.

Even after suppressing the warning, I still get the error and can't reference the library. How can I get this reference resolving?

Very easy to repro:

  1. New .net core 2.0 console app
  2. Copy the method from the above question
  3. Try to install the nuget package

C# Solutions


Solution 1 - C#

The package is not fully compatible with dotnetcore 2.0 for now.

eg, for 'Microsoft.AspNet.WebApi.Client' it maybe supported in version (5.2.4). See Consume new Microsoft.AspNet.WebApi.Client.5.2.4 package for details.

You could try the standard Client package as Federico mentioned.

If that still not work, then as a workaround you can only create a Console App (.Net Framework) instead of the .net core 2.0 console app.

Reference this thread: https://stackoverflow.com/questions/43118384/microsoft-aspnet-webapi-client-supported-in-net-core-or-not

Solution 2 - C#

For me, I had ~6 different Nuget packages to update and when I selected Microsoft.AspNetCore.All first, I got the referenced error.

I started at the bottom and updated others first (EF Core, EF Design Tools, etc), then when the only one that was left was Microsoft.AspNetCore.All it worked fine.

Solution 3 - C#

That particular package does not include assemblies for dotnet core, at least not at present. You may be able to build it for core yourself with a few tweaks to the project file, but I can't say for sure without diving into the source myself.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBLAZORLOVERView Question on Stackoverflow
Solution 1 - C#Andy Li-MSFTView Answer on Stackoverflow
Solution 2 - C#EricView Answer on Stackoverflow
Solution 3 - C#Markus KitsingerView Answer on Stackoverflow