NuGet API获取软件包的版本 [英] NuGet API Get Version of package
问题描述
我正在尝试从软件包中获取最新版本(在我的情况下,我尝试使用StyleCopAnalyzer软件包
I am trying to get the newest version from a package (in my case im trying it with the StyleCopAnalyzer Package https://www.nuget.org/packages/StyleCop.Analyzers).
我的目标是找出此软件包的最新版本,并通过以下get api调用进行尝试:
My goal is to find out what the newest version of this package is, im trying this with the following get api call:
https://api.nuget.org/v3/registration3/StyleCop.Analyzers/index.json
由于请求中的一些错误,我得到了这个json:
Due to some mistakes in the request, i get this json back:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Error>
<Code>BlobNotFound</Code>
<Message>The specified blob does not exist. RequestId:c2c2ffba-701e-0063-0daa-e47670000000 Time:2019-03-27T14:38:14.3708948Z</Message>
</Error>
我在此文档的帮助下创建了此请求:
I created this request with the help of the this doc:
https://docs.microsoft.com/en-us/nuget/api/overview
预先感谢您的帮助.
推荐答案
Elaborating on @zivkan
's answer, I found this post useful for background context.
需要特别注意的是NuGet服务器维护者宣布将添加对"semver 2.0"的支持.通过此端点打包:
Of particular note is where the NuGet server maintainers announce that they will be adding support for "semver 2.0" packages via this endpoint:
今天,从api/v3/index.json中可以看到两个注册配置单元:
Today, there are two registration hives visible from the api/v3/index.json:
- https://api.nuget.org/v3/registration1/
- https://api.nuget.org/v3/registration1-gz/
我们将添加第三个:
对我来说,通过文档并不清楚的是semver2
端点也返回了非第二版软件包的元数据(根据反思,这与semver 1.0之后的任何软件包都有意义约定与semver 2.0向前兼容)
What wasn't obvious to me through the docs is that the semver2
endpoint returns metadata for non-semver 2 packages as well (upon reflection, this makes sense as any package following semver 1.0 conventions is forward-compatible with semver 2.0)
我已更新代码以不再使用
https://api.nuget.org/v3/registration3/
在任何情况下都始终使用 https://api.nuget.org/v3/registration5-gz-semver2
.
I've updated my code to no longer use
https://api.nuget.org/v3/registration3/
in any context and always use https://api.nuget.org/v3/registration5-gz-semver2
.
此更改简化了我的验证代码,其中包括程序包I正在寻找 (以及其他121个).
This change simplifies my validation code, includes the package I was looking for (as well as 121 others).
Peter K
的软件包可以使用以下方式解决:
Peter K
's package can be resolved using:
https://api.nuget.org/v3/registration5-gz-semver2/stylecop.analyzers/index.json
这篇关于NuGet API获取软件包的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!