MSBuild 15 has a /t:restore option that does this. it comes with Visual Studio 2017.
If you want to use this, you also have to use the new PackageReference, which means replacing the packages.config
file with elements like this (do this in *.csproj):
<ItemGroup>
<!-- ... -->
<PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.0" />
<!-- ... -->
</ItemGroup>
There is an automated migration to this format if you right click on 'References' (it might not show up if you just opened visual studio, rebuild or open up the 'Manage NuGet packages for solution' window and it will start appearing).