Search code examples
yamlazure-pipelinesnuget-package

Azure DevOps Pipeline task DownloadPackage@1 omits nuget package version


I have an Azure DevOps artifact feed that hosts NuGet packages. I am trying to download a NuGet package from it using a Pipeline task DownloadPackage@1.

`

- task: DownloadPackage@1
  inputs:
    packageType: 'nuget'
    feed: 'RandomFeed'
    definition: 'MyPackage'
    version: '1.0.0.0.'
    downloadPath: '$(System.ArtifactsDirectory)'

`

When I download it manually from the feed or with API, the package is downloaded with its full name and version appended - MyPackage.1.0.0.0.nupkg

When I try to use the DownloadPackage@1, the downloaded package has it's version omitted and only the title remains - MyPackage.nupkg

Is there a way to download the nuget from the feed with its full name ? I target to use the integrated Pipeline tasks so I can use the System.AccessToken for the Pipeline and not use additional ones for example to fetch it from the API.


Solution

  • If you want to use the System.AccessToken for pipeline to authorize, you can only use the DownloadPackage task in pipeline.

    For using PAT (Personal Access Token) to authorize, you can first create a service connection credential for the feed.

    enter image description here

    Add NuGet authenticate task in the pipeline. enter image description here

    Then use PowerShell task in line script to download NuGet packages. The inline script: nuget install {package name} -version {package version} -Source https://pkgs.dev.azure.com/{orgname}/_packaging/{feedname}/nuget/v3/index.json

    enter image description here