NuGet not restoring packages on build

I have the same issue, also on the local machine. Although both Package Manager Console and nuget.exe restore MySolution.sln report that everything is installed, there is no packages folder to be found in the solution directory and no references to packages are being resolved.

I checked all project files and they expect packages to be placed in ..\packages folder, the same folder where the solution file itself is located.

The way I made it work is to run:

nuget.exe restore MySolution.sln -PackagesDirectory packages

This forced nuget.exe to download all packages to the specified folder and all references were restored.

Remember that from NuGet 2.7, the targets file is not supported, msbuild suppose to use some integrated way of restoring packages but it fails very often.

In fact, for my own work I prefer using Paket, which always work, when you get used to it. It also supports target files and nice way to create NuGet packages.


Have you deleted the NuGet.targets file from disk too?

If the NuGet.targets file is there, Visual Studio / NuGet.exe will try to do the MSBuild package restore.

See this doc for more info.


I had to go into Source Control and delete all of the files in the packages folder (except repositories.config) before NuGet would restore the missing packages. The idea is that you are using package restore rather than checking your packages in to source control. If it sees the packages in source control, it won't download them.