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
Woot!