35

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!

7
  • It might be that this option is not available in Visual Studio Express (if you're using this). Maybe try and get your hand on Visual Studio Professional or Ultimate? 2013 would be a good choice. I've had trouble with Google documentation as well.
    – mihai
    Oct 11, 2014 at 15:55
  • I don't think it's Express, it's just Visual Studio 2013. Oct 11, 2014 at 16:07
  • See: xavierdecoster.com/… Oct 11, 2014 at 16:20
  • Go to Help -> About Microsoft Visual Studio. You can see there what variant you have (Express, Professional or Ultimate). Express is free of charge, Professional is about $300 and Ultimate about $10000. The more expensive, the more features it has. I have the Professional version, and the feature you mention is available.
    – mihai
    Oct 11, 2014 at 16:50
  • 10
    Right click on the solution rather than the project.
    – idursun
    Oct 11, 2014 at 17:16

7 Answers 7

52

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?

5
  • Apparently you also need to enable on Project basis as well Oct 11, 2015 at 18:39
  • If I right-click on a project I don't see "Enable Nuget Package Restore", unlike when right clicking on the solution. So what do we need to enable on Project basis as well? Oct 12, 2015 at 9:23
  • Once enabled, the option disappears. We're probably using slightly different versions or configured solutions. My response is probably situational. Still helped me, but I'd suggest adding this to your answer. Ronalds has the other part. Oct 12, 2015 at 12:14
  • 2
    So simple - so hard to find =D Thank you! Saved my day! Oct 19, 2015 at 18:31
  • This fixed my issue. Jul 29, 2019 at 15:31
27

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

5
  • 1
    Does this mean that with every build your nuget packages are restored? Doesn't this slow down my builds considerably? Aug 27, 2015 at 15:03
  • 1
    @HaraldDutch only if they are missing, if the packages are already there it doesn't cause any additional slowdown.
    – John
    Sep 8, 2015 at 22:38
  • This answer seems to miss the point. Solutions and Projects seem to be auto configured NOT to auto update Nuget packages. I had the latest Nuget and was not getting missing DLL's on build. After I enabled "Nuget Package Restore" Solution and Project levels, they were all updated on build. @HaraldDutch, has the right direction. Oct 11, 2015 at 18:42
  • @DaveAlperovich except, you don't want to use that version of nuget package restore! The version I'm talking about happens automatically and has been like that since 2013 when nuget 2.7 released. docs.nuget.org/consume/package-restore
    – John
    Oct 12, 2015 at 22:50
  • If you have previously enabled automatic restore (with old nuget aka MSBuild-integrated restore) and then want to move to the new automatic restore VS will get very confused. Follow the instructions under Migrating to automatic restore here: learn.microsoft.com/en-us/nuget/consume-packages/…
    – mattumotu
    Jun 28, 2017 at 15:21
12

Rename your .nuget folder then right-click on your solution. Enable Nuget package restore should then be visible.

1
  • 1
    Way too elaborate. Right click on the solution (not project!) where you can find "Manage Nuget Packages for Solution". There you can check: "Allow Nuget to download missing packages" Jul 28, 2015 at 6:27
6

I think you just want to know where to enable "Allow Nuget to download missing packages"

In VS2013: Right Click on the project Select "Manage NuGet Packages for Solution" Then Click on "Settings" in new dialog click on "Manage NuGet Package Manager" root level Tick/Untick "Allow NuGet to download missing packages"

0
4

I had this problem and found a fix that may or may not work for you. I had to edit the csproj files because they were pointing to wrong or non-existent packages folders.

Look for the reference paths in your csproj file and be sure the packages folder path is correct:

<HintPath>..\packages\path\to\file.dll</HintPath>

Maybe because of an unusual folder setup, that needs to be ..\..\packages. Also, towards the top, NuGet adds this line:

<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>

If you had to edit your HintPaths, you probably also need to edit this. In my example you'd change the value to ..\..\. Finally, at the bottom, NuGet adds a target with the name EnsureNuGetPackageBuildImports. You'll see a couple of attributes with the ..\packages paths in them. Again using my example, you'd have to change this to ..\..\packages. The base for all of these values is of course the folder containing the csproj file.

It may be unusual for your folder paths to be set up in a non-default manner, but mine were, and this information would have been useful to me.

3
  • 1
    Yes, I copied the whole solution folder to another location which caused NuGet problems. As you suggested the project file still had some relative paths to now missing folders. Manual editing of the project file fixed that.
    – mp31415
    May 23, 2015 at 0:27
  • It works for me. Btw, edit the place we put nuget packages is another option. In order to do so, just need to add config in the nuget.config file <br/> <config> <add key="repositorypath" value="$\..\..\..\Packages" /> </config> <br/> stackoverflow.com/a/19259947/2793768
    – Chinh Phan
    Oct 5, 2015 at 4:14
  • Although I'm not upvoting because it doesn't seem to be specific to the question, I'm very glad that you posted this answer because it helped me with a very specific problem of my own - I had hint paths in a long ago project which was no longer correct. Fixing them up and everything worked. So thanks!
    – Alex White
    Oct 27, 2015 at 12:46
1

If you right-click on a project, and don't see the option to "Enable Nuget Package Restore", The reason why you do not SEE this option is because you do not have the latest version of nuget package installed in Visual Studio.

The following steps will show you how to install the appropriate nuget package for the version of Visual Studio you are using. Click on Tools->Extensions and Update. Extensions and Update Dialog will appear. Click on online in the left hand column of the dialog. You should see as first package in list "Nuget Package Manager for Visual Studio 2013. Click on the 'download' button to install. You may then have to restart Visual Studio.

Now re-open your solution and right-click on the solution name. You should now see a dialog popup asking you if you want to restore packages for this solution. If you select 'yes' then anytime you build your solution nuget will attempt to download and of the corresponding packages your solution is using.

0

In my situation, I just created a new solution and the solution file hadn't been saved yet. Make sure the solution is saved before "Enabling Nuget Package Restore"

2
  • Could you elaborate?
    – Kmeixner
    Apr 14, 2016 at 17:10
  • @Kmeixner Because I had to generate a new solution from a number of projects, a new solution (.sln) file had not been saved. The "Enabled Nuget Package Restore" does not show when you right click until you create the solution file.
    – nwestfall
    Apr 14, 2016 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.