Could not install package 'NuGet.Client 3.2.0' - nuget

I'm working with RESTful webservice, getting error while adding package "System.Net.Http";
"The 'System.Net.Http 4.0.0' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.5.0'. "
So, to resolve above error i'm trying to install "NuGet client" from "Add Package" option in xamarin studio, but this time I'm facing another issue that is;
"Could not install package 'NuGet.Client 3.2.0'. You are trying to install this package into a project that targets 'portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."
please help to resolve this issue.

Xamarin Studio currently does not support NuGet 3. It is currently only supported in Visual Studio 2015.
It is not possible to upgrade Xamarin Studio so it supports NuGet 3 at this time. Installing the NuGet.Client NuGet package does not upgrade NuGet in Xamarin Studio.
I would instead look at using the Microsoft.Net.Http NuGet package which you can install into a portable class library project (PCL) and supports all Xamarin Android and Xamarin iOS projects.

I was able to grab a copy of System.Net.Http.dll from another project and manually add it as a reference to my Xamarin project. I put it in the packages folder and then browsed to it from the edit references dialog.

For people facing problem trying to add System.Net.Http...
I was able to solve the problem by using Microsoft.Net.Http instead of System.Net.Http. In Xamarin studio, Right click on your project > Add > Add NuGet Packages.. > search for "Microsoft Http Client Libraries" and click Add Package.

Related

Why is the latest stable version of Newtonsoft showing in Nuget Package Manager as 12.0.3 in one project and as 9.0.1 in another?

In my class library, Manage Nuget Packages shows the latest stable version of Newtonsoft as 12.0.3. In another application that references the class library, Manage Nuget Packages shows the latest stable version of Newtonsoft as 9.0.1
What would explain that difference, and how is it fixed in Visual Studio 2019? When I try to compile the application, it fails with the error that the class library's version of Newtonsoft is newer.
EDIT: I think I've found the reason: in the top right corner of the window the package source for the application was not nuget.org but Visual Studio Offline Sources.
Why is the latest stable version of Newtonsoft showing in Nuget
Package Manager as 12.0.3 in one project and as 9.0.1 in another?
When you install a nuget package, you should select the right nuget package source.
As it shows that, Visual Studio Offline Sources is your local nuget caches. It is required that you download the corresponding nuget version and then exist in this data source. So it depends on you and not all versions of the package are fully displayed.
nuget.org is the ultimate destination for developers releasing nuget packages. You can find every version of the package here. So you should check this link.
Check and enable that link.
Then, open Nuget Package Manager UI and choose nuget.org and you can find it.

Visual Studio 2017: Package Restore failed, Rolling back Package changes for 'Projectname'

Added the new Package using Package Manager console or manage nuget packages in Project it's not added project it's Throw below Error.
I was Check some Links Not give proper reason. why this problem in coming in vs2017
Anyone Know Share the knowledge.
Thanks in Advance
Visual Studio 2017: Package Restore failed, Rolling back Package changes for 'Projectname'
You could not install the package exceldatareader.dataset to the UWP project. That because this package only have the .NET Framework assemblies, which is not compatible with UWP project. You can download that package from nuget.org, then open it, you will find this package only have the assemblies for .NET 2.0 and .NET 4.5:
So this package is not compatible with UWP project, you can find the error message in the output window when you install it to the UWP project:
Hope this helps.

Where is NuGet in VS2017 Community?

Just installed VS2017 Community edition -- I read some doc saying that NuGet is included -- but I don't see it and don't see how to add it. Should it appear basically as it did in VS2015?
You have to find it in the installer, second tab - "Packages", under the subheading "Code Tools"
You can launch the installer from the Tools menu in VS, it should be the first option.
I had the same issue. When I installed VS 2017, I only had Microsoft Visual Studio Offline Package. I can't remember how I figured it out, but I did. What you have to do is:
Open VS 2017.
Select Tools > NuGet Package Manager > Package Manager Settings.
In Options, select NuGet Package Manager > Package Sources.
Select + next to Available package sources.
Enter these values:
Name: nuget.org
Source: https://api.nuget.org/v3/index.json
Select OK.
Now, when you run Install Package commands, you'll get what you need.
NOTE: In the Package Manager Console, as your Package source, make sure you select All or nuget.org.
It was included as an option, NOT installed by default.
To install NuGet:
1. Tools > Get Tools and Features...
2. Single Component > Code Tools
3. √ NuGet package manager
4. update.
To find NuGet:
- Project > Manage NuGet packages...
- Tools > NuGet Package Manager
Project or Tools
In Visual Studio 2017,
Click on Tools -> Nuget Package Manager -> Package Manager Console :)
For anyone who stumbled across this question while trying to find out where nuget was installed to use it as a CLI, if you didn't install it individually you need to use it through MsBuild.exe's use of /t:restore to for example restore nuget packages. You'll have to install the individual component if you want the full tool and not just calls to a DLL via MSBuild.

dotnetcore Nuget enable Pre-Release

I've started using dotnetcore for a hobby project.
I'm having an issue trying to install NLog. The Visual Studio Code editor seems to recognise the beta version as the intelisense suggests it inside the project.json file. However nuget doesn't seem to restore it.
Is there a way to enable pre-release on Nuget packages in the new dotnet core platform?
Is the package on the Nuget repo? Check this link to see if its listed:
https://www.nuget.org/packages/NLog
If it's on there you can just add it to your project.json and then run a dotnet restore to install the nuget, no intellisense required.
I came across the answer to my question whilst watching a PluralSight video on Entity Framework Core By Dr Scott Allen.
One option is to use the visual studio package manager console and use the -pre flag. e.g:
install-package Microsoft.EntityFrameworkCore.tools -pre

How can I add libraries to Xamarin Mono for Android project in VS2010?

I am working on a mono for Android application (my very first) that consumes a web api. In the documentation at xamarin.com there are examples on using different libraries such as RestSharp and Json.Net.
However, when I try to install these libraries via Nuget in my VS2010 project it failes with the following message:
Install failed. Rolling back... Could not install package
'Newtonsoft.Json 4.5.9'. You are trying to install this package into a
project that targets 'MonoAndroid,Version=v2.2', but the package does
not contain any assembly references that are compatible with that
framework. For more information, contact the package author.
How can I include such libraries in my project?
Thanks in advance.
Erwin
This error message indicates those libraries are not compatible with Mono for Android. You should ask the manufacturer of the libraries if they have a MfA compatible version. If you have the source code of the libraries you could also try to make a MfA library, using linked source files, yourself.
Not sure if you've tried this but if you're using xamarin studio and right click the component folder in your Android app project choosing add component should be able to solve your problem. This will add a reference to the component that is added. Components seem like they are mono compatible packages and what's good for your case is that there are components for both RestSharp and Json.Net:
https://components.xamarin.com/view/restsharp
http://components.xamarin.com/view/json.net/