I've used Xavier's answer quite a bit. I want to add that restricting the package version to a specified range is easy and useful in the latest versions of NuGet.
For example, if you never want Newtonsoft.Json
to be updated past version 3.x.x
in your project, change the corresponding package
element in your packages.config
file to look like this:
<package id="Newtonsoft.Json" version="3.5.8" allowedVersions="[3.0, 4.0)" targetFramework="net40" />
Notice the allowedVersions
attribute. This will limit the version of that package to versions between 3.0
(inclusive) and 4.0
(exclusive). Then, when you do an Update-Package
on the whole solution, you don't need to worry about that particular package being updated past version 3.x.x
.
The documentation for this functionality is here.