Wednesday, April 29, 2015

Bulk Nuget updates

This article is really old and the instructions are unlikely to work correctly any more. There might be some newer and safer way of performing bulk NuGet updates across many projects, but maybe that's just too dangerous in general these days.

Every few months I need to bulk update all of my VS2015 projects to use the latest version of a certain package. Because I spent another 10 minutes stuffing around to get the correct syntax, I'm putting it in here so I won't forget again. The following command recursively loops down looking for *.sln files and runs a nuget update against them.

for /R %f in (*.sln) do nuget update "%f" -id packagename

If the solution's projects do not contain the package id you will get this for each project:

Updating 'project name'...
WARNING: Unable to find 'packagename'. Make sure they are specified in packages.config.

If the solution's projects do not use Nuget then you get:

Scanning for projects...
No projects found with packages.config.

If a solution's project is updated you get this without a following warning message:

Updating 'project name'...

The resulting output from processing many solutions and projects can be quite cluttered and difficult to read to see what really happened.

UPDATE NOTE -- December 2015

Solutions containing web projects don't seem to upgrade correctly using the technique described above. I found I had to open these solutions in Visual Studio and manually update the packages. I haven't diagnosed the details of this issue yet, so this is just a friendly warning.

No comments:

Post a Comment