How do I enable the nuget package restore feature in Visual Studio 2015?
The feature is just missing in my context menu (Yes - I've double checked that I try it on the solution instead of a project)
My only project is a .NET 4.5 console application - there is no .nuget folder yet. There is an actual nuget package installed.
It is available in the main menu (Tools | NuGet | NuGet Force Restore) or in the NuGet quick list Alt+Shift+N .
Open the project/solution in Visual Studio, and open the console using the Tools > NuGet Package Manager > Package Manager Console command.
I had the same problem as you and the way I solved it was to delete the packages
folder from my solution and also bin
and obj
folders from every project in the solution and give it a rebuild.
As it turns out, the real solution is to migrate to Automatic Package Restore. We experienced issues with NuGet after upgrading to VS 2015 after working in 2013 for a while. Turns out the old way of doing NuGet completely hoses the new way of doing it.
The solution is simple, though tedious. Apparently the NuGet.targets file signals VS to use the old NuGet way of doing things, and it's absence means that you are now using "Automatic Package Restore". You can migrate to Automatic Package Restore by following these steps:
<RestorePackages>true</RestorePackages> ... <Import Project="$(SolutionDir)\.nuget\nuget.targets" /> ... <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>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 {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> </Target>
There is also a powershell script that will perform the migration for you, if you are feeling bold. You can find it on github.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With