Restore NuGet packages from packages.config

Another in my occasional series of wrangling with NuGet within Visual Studio.

This one is to restore all packages from a packages.config file:

  function Restore-Packages() {
    $proj = get-project
    get-package -project $ | % {
      Write-Host $;
      uninstall-package -projectname $ -id $ -version $_.version -RemoveDependencies -force ;
      install-package -projectname $ -id $ -version $_.version

To use, first edit the packages.config as you require. Then, in the Package Manager Console in VS (in the ‘default project’ dropdown set correctly), just type:

[sourcecode language=”powershell”] Restore-Packages [/sourcecode]


May 13, 2013 nuget powershell