Tuesday, August 26, 2014

A safer way to upgrade your NuGet packages

Updating all your NuGet packages for a solution is easy thanks to the ‘Update-Package’ command or through the ‘Update All’ option when using the UI. However it’s always a tricky practice as a lot of things can go wrong. Worst case you end up with a set of incompatible updates causing breaking changes,  strange behavior and unexpected errors. Fun!

So most of the time I try to avoid any NuGet update unless it’s really necessary. Until I discovered a new option for the Update-Package command:

Update-Package -Safe

The “Safe” switch will only upgrade Revisions and will not touch Major and Minor versions. So if all your NuGet packages follow the semantic versioning rules, this is a great solution avoiding lots of problems.

If only I knew about this option before…

No comments: