nugetninja

Advanced nuget command line ninjary

Small post here, but I just wanted to post something. It’s been too long. Smile

I had a need yesterday to reinstall a group of nuget packages and didn’t want to go through 8 pages of packages in VisualStudio, hand picking the ones I wanted to reinstall. Nor did I want to type update-package <package name> –reinstall for every single page, mostly because I couldn’t easily remember the names of all the packages that needed reinstalling.

Also, update-package doesn’t have a way to specify a wildcard, so you can’t do something like update-package *DefinitelyTyped*.

But then I remember that there’s power in PowerShell.  Behold…

get-package | where Id -like “*DefinitelyTyped*” | foreach { update-package $_.Id  -reinstall }

Pretty rad. I had never heard of get-package before I wrote that line. So then I though, can I install every DefinitelyTyped package at once?

And just for fun, what if I wanted to install every DefinitelyTyped package related to Bootstrap?

get-package -ListAvailable | where {($_.Id -like “*DefinitelyTyped*”)-and ($_.Id -like “*bootstrap*”) } | foreach { install-package $_.Id }

Done.

What other clever ways have you combined PowerShell and nuget?

Leave a Reply