我有兴趣使用非 .NET 语言为 NuGet v3 API 编写客户端库。
获取包裹需要哪些请求,响应是什么样的?
i.e.
获取{包版本}
获取{包版本}
您还可以链接到涵盖此场景的官方文档吗?
Here https://learn.microsoft.com/en-us/nuget/api/overview是官方 NuGet V3 API 文档。 API由多种协议组成,包括:
- The 包基址 https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource- 包含实际包及其清单文件(
nuspec
).
- The 服务指标 https://learn.microsoft.com/en-us/nuget/api/service-index- 客户端用来发现 NuGet 服务
- The 搜寻服务 https://learn.microsoft.com/en-us/nuget/api/search-query-service-resource- 客户端用来搜索 NuGet 包
- The 登记 https://learn.microsoft.com/en-us/nuget/api/registration-base-url-resource- 基于 json-LD 的结构,用于存储包的元数据。这包括包的内容、依赖项、描述等......
例如,假设您想下载软件包“Newtonsoft.dll”。
杰森”:
- 获取服务索引:`GEThttps://api.nuget.org/v3/index.json https://api.nuget.org/v3/index.json
响应包含 PackageBaseAddress 的地址(也称为扁平容器,因为它是分层的而不是扁平的:)):
{
"@id": "https://api.nuget.org/v3-flatcontainer/",
"@type": "PackageBaseAddress/3.0.0",
"comment": "Base URL of Azure storage where NuGet package registration info for DNX is stored, in the format https://api.nuget.org/v3-flatcontainer/{id-lower}/{version-lower}.{version-lower}.nupkg"
},
- 使用@id提供的uri作为基本uri来列出所需包的版本:
GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
,请注意,此 uri 可能会更改,并且不是 API 的一部分
- 使用相同的基本 uri 下载包:
GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/6.0.4/newtonsoft.json.6.0.4.nupkg
您可能还想查看NuGet客户端 https://learn.microsoft.com/en-us/nuget/reference/nuget-client-sdk。客户端的源代码是here https://github.com/nuget/nuget.client;你会想从NuGet.CommandLine 项目 https://github.com/NuGet/NuGet.Client/tree/dev/src/NuGet.Clients/NuGet.CommandLine然后沿着堆栈往下走。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)