Enable NuGet Package Restore on Visual Studio 2013

故事扮演 提交于 2019-11-29 13:07:04

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?

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

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

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"

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.

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.

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"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!