List all available versions of a specific package in NuGet Package Manager Console

前端 未结 3 1424
孤城傲影
孤城傲影 2021-01-31 07:13

What NuGet PowerShell command will return a list of all versions of a specific package?

I have tried the following, but it only returns one version of NUnit along with a

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-31 07:49

    To extend on the already provided solutions and address the follow-up questions by King King and JohnKoz, it is possible to get the full list of versions for a specific package as follows:

    Find-Package -AllVersions -source https://nuget.org/api/v2/ Newtonsoft.Json -ExactMatch | foreach { $_.Versions } | Select-Object Version
    

    The package Newtonsoft.Json is an example. Replace it as needed.

    It works by first getting all versions for a single package (via -ExactMatch). This returns a package object that has a Versions property, which is an array of version objects. The foreach iterates over all these and the Select-Object ensures that each version object is output as a single line (by only selecting its main property).

提交回复
热议问题