NuGet API 获取包的版本 [英] NuGet API Get Version of package
问题描述
我正在尝试从包中获取最新版本(在我的情况下,我尝试使用 StyleCopAnalyzer 包 https://www.nuget.org/packages/StyleCop.Analyzers).
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/概览
预先感谢您帮助我.
推荐答案
详述@zivkan
的答案,我找到了 这篇文章对背景上下文很有用.
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:
我们将添加第三个:
通过文档对我来说并不明显的是 semver2
端点也返回 non-semver 2 包的元数据(经过反思,这是有道理的任何遵循 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
.
此更改简化了我的验证代码,包括包我正在寻找 (以及其他 121 个).
This change simplifies my validation code, includes the package I was looking for (as well as 121 others).
Peter K
的包可以使用:
https://api.nuget.org/v3/registration5-gz-semver2/stylecop.analyzers/index.json
这篇关于NuGet API 获取包的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!