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 $proj.name | % {
    Write-Host $_.id;
    uninstall-package -projectname $proj.name -id $_.id -version $_.version -RemoveDependencies -force ;
    install-package -projectname $proj.name -id $_.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:

Restore-Packages

Enjoy.

About these ads

Posted on May 13, 2013, in Uncategorized and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 260 other followers