简体   繁体   中英

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?

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

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?)

另一种方法是在页面底部的nuget.org的包网页中找到RSS源。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM