Search code examples
azure-devopsfeedartifact

Azure DevOps feed get download url for a latest version of the nuget package or symply download latest package


I've got the Azure DevOps pipeline which builds nuget package and deploys it to Azure DevOps feed. In the portal I can find download link to a specific version of the package. How do I find url to download latest version of the nuget package in the feed?

Alternatively how do I download the latest version of the package? Ideally just via curl, dotnet or anything what is resent on dev windows machine and in general docker sdk image. I tend to go long way

  • dotnet new console
  • add package
  • restore find the location of the file. But I really don't like this approach. Anything nicer?

Solution

  • How do I find url to download latest version of the nuget package in the feed?

    Please follow below steps to find this url.

    1. Use this Rest API: Feed Management - Get Feeds to get the feed id.
    2. Use this API: Artifact Details - Get Packages to get details about the target package in the feed. Url looks like: https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/Feeds/{feedId}/packages?packageNameQuery={packageName}&api-version=6.0-preview.1. From the response, you will find its versions array, and the latest version is marked by "isLatest":true, so you get the latest version of this package in this feed.
    3. This Rest API: NuGet - Download Package provides the url to download latest version of the nuget package in the feed.

    BTW, please note that the project parameter in above APIs must be supplied if the feed was created in a project. If the feed is not associated with any project, omit the project parameter from the request.