Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I automatically detect whether my NuGet packages are up to date?

I'd like to get loud warnings somewhere if my project is using a dependency that's now out of date (potentially I might hook this into our build, so builds using certain outdated dependencies are automatically failed and can't be deployed).

If possible I'd like to do this for dependencies on our other internal projects only, to start with, so that if I publish a new version of a shared internal library, all other projects using that library are loudly notified/required to update to the new one, but so we don't have to immediately upgrade to the newest version of entity framework every time it's upgraded.

Is there a way to easily check whether all or a subset of my NuGet dependencies are up to date from the package manager console, or with an MSBuild task?

like image 808
Tim Perry Avatar asked Feb 26 '14 12:02

Tim Perry


3 Answers

You can get a list of all your installed packages and the latest version on NuGet.

I created a PowerShell script to do this. You can find it here:

Nuget, compare installed vs latest version

like image 88
Kiliman Avatar answered Oct 12 '22 18:10

Kiliman


An alternative is to suscribe to the RSS feed found in the package webpage at nuget.org, at the bottom of the page.

like image 24
Hugo Laf Avatar answered Oct 12 '22 17:10

Hugo Laf


If desired it's possible to manually query the public API for NuGet to retrieve package information. They have a newer JSON api which i was able to use in a NodeJS app, and they have an older XML api.

JSON api

https://api.nuget.org/v3/index.json

All versions of a package: https://api.nuget.org/v3/registration0/newtonsoft.json/index.json

Specific package at version: https://api.nuget.org/v3/registration0/newtonsoft.json/4.0.1.json

(keep in mind that the package ID in the URL must be all lowercased!)


XML api

https://nuget.org/api/v2/

All Packages (paged -first 100): https://www.nuget.org/api/v2/Packages

Next page of 100: https://www.nuget.org/api/v2/Packages?$skip=100

Specific package at version: https://www.nuget.org/api/v2/Packages(Id='NewtonSoft.Json',Version='4.0.1')

With the XML version I don't know of a way to list all versions of a package, but when you visit the versioned package there is a boolean value for <d:IsLatestVersion> and <d:IsAbsoluteLatestVersion> (I'm not sure what the difference is though... perhaps one exclude pre-release versions?)

like image 35
FiniteLooper Avatar answered Oct 12 '22 18:10

FiniteLooper