How to install a package into all projects of a solution

Saturday, Feb 26, 2011 1 minute read Tags: nuget
Hey, thanks for the interest in this post, but just letting you know that it is over 3 years old, so the content in here may not be accurate.

This is a script that I’ve been keeping in my toolbox since NuGet was first released.

Ever now and then I need to do an install of a package across all projects in a solution. log4net is an example of the kind of thing you’d want to globally install, so is Autofac.

Well here’s a script to run from the Package Management Console:

Get-Project -All | Install-Package packageName

This is also available as a gist.

Note: replace packageName with what you want to install ;).

Challenge to the reader

*Update: With a tip-off from David Fowler you can compress the script even more. If you want to see the original just check out the gist history.

Installing into a project subset

Since this is just a powershell script you can also apply filters, so if you have say multiple test projects you do run this:

Get-Project -All | where { $_.Name.EndsWith(".Test") } | Install-Package NSubstitute