Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable NuGet Package Restore on Visual Studio 2013

I'm following this easy tutorial to start coding with the Google+ API in C#. However, I've been stuck for hours on Step 3, where the first substeps are:

  1. In Visual Studio, click Project > Enable NuGet Package Restore > answer Yes in the dialog.
  2. Right-click on the gplus-quickstart-csharp project and select Manage NuGet Packages.
  3. Click Restore on the Manage NuGet Packages window. This will install the Google API Client libraries.

When I click on Projet, there is no option "Enable NuGet Package Restore".

There is a Manage Nuget Packages option, but no Restore button or option whatsoever.

The project doesn't build and gives me the error:

Error 1 This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is C:\Users\Documents\google+\gplus-quickstart-csharp\.nuget\NuGet.targets. C:\Users\Documents\google+\gplus-quickstart-csharp\gplus-quickstart-csharp\gplus-quickstart-csharp.csproj 201 5 gplus-quickstart-csharp

I went on the microsoft website and it only redirects to the NuGet documentation where I didn't find anything that works. I tried the following commands (described in the examples):

  • D:\projects\contoso> nuget.exe restore
  • D:\projects\contoso> nuget.exe restore contoso.sln
  • D:\projects> nuget.exe restore contoso

but to no avail. And yes, NuGet is installed. Any ideas? Thanks!

like image 246
user3180077 Avatar asked Oct 11 '14 14:10

user3180077


People also ask

How do I install a NuGet package in Visual Studio 2013?

Add The NuGet Package to you ProjectRight-click on the project's References and click Manage NuGet Packages. In the NuGet Package Manager, select online from the menu and search “New NuGet Package” and click Install.


2 Answers

To find the menu item: "enable nuget package restore" right-click in the solution explorer on the solution - not on the project.

You get a message:

Do you want to configure this solution to download and restore missing NuGet packages during build?

Wasn't that what you were looking for?

like image 172
Harald Coppoolse Avatar answered Sep 22 '22 03:09

Harald Coppoolse


You don't want to use the project based nuget package restore!

Make sure you have the latest Nuget version (Tools -> Extensions and Updates)

When you go to build the project it should tell you it needs to download the nuget packages (or might just auto download them).

Edit not sure whats with the downvotes:

http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

What the NuGet team is now recommending is both a lot cleaner and a lot simpler. In short, you don't do anything special, and it just happens! This is because NuGet now always restores packages before building in VS. So no changes whatsoever are needed on your files, which is beautiful!

Since people are still having issues editing to include more information:

https://docs.nuget.org/consume/package-restore#common-issues-with-automatic-package-restore

like image 40
John Avatar answered Sep 23 '22 03:09

John