简体   繁体   中英

Azure DevOps dotnet restore task fails due to wrong URL format on Nuget artifact feed

I have the following restore task in a YML file:

- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore
    feedsToUse: select
    vstsFeed: MyFeedName

But the restore action fails, due to a wrong feed URL, which comes out like this in the log: https://pkgs.dev.azure.com/<organization_name>/_packaging/MyFeedName/nuget/v3/index.json

Based on the "Connect to feed" information from DevOps, the URL is supposed to be in this format: https://pkgs.dev.azure.com/<organization_name>/<guid>/_packaging/MyFeedName/nuget/v3/index.json

So, it seems like it doesn't insert the <guid> part which makes it fail. I can't figure out how to configure the task in YAML, such that it uses the right URL. How do I do this?

it seems like it doesn't insert the part which makes it fail. I can't figure out how to configure the task in YAML, such that it uses the right URL. How do I do this?

This <guid> is the id of your current project. When you add this DotNetCoreCLI@2 task to your yml file, the vstsFeed 's value should be like this format: {projectid}/{feedid} .

For example,

- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'select'
    vstsFeed: '54cc87c1-****-****-****-************/ff77923d-****-****-****-************'

If you don't know how to get your ProjectId , please refer to the Rest Api doc: Projects - List .

You can call it in Postman, like below:

在此处输入图像描述

Or, you can directly use the Feed Management - Get Feeds to get both your project id and feed id at the same time:

在此处输入图像描述

vstsFeed is expecting {projectid}/{feedid} , not the full feed URL https://pkgs.dev.azure.com/{Organization Name}/{Project Name}/_packaging/{Feed Name}/nuget/v3/index.json . These ids, which are GUIDs can be found using the following steps.

In Azure DevOps open your project, select Artifacts, select the feed you want from the dropdown and clicking on the 'Connect to Feed' button. Then select Visual Studio, copy the machine setup source URL and enter the URL https://pkgs.dev.azure.com/{Organization Name}/{Project Name}/_packaging/{Feed Name}/nuget/v3/index.json into your browser.

You can copy and paste the resulting JSON into an new file in Visual Studio Code and press Alt-Shift-F to format or use a browser extension like JSON Formatter for Edge to make the JSON legible.

Anyone of the URLs provided in the resources contain the project id (first GUID) and the feed id (second GUID). For example from the URL…

https://pkgs.dev.azure.com/someorganization/acbd5515-415a-47fb-a0fb-d8880726b180/_packaging/1c7d43be-a18a-4567-ac5b-f8a8bd0f7617/nuget/v2/

You would add the following YMAL to your build pipeline.

- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: 'restore'
    feedsToUse: 'select'
    vstsFeed: 'acbd5515-415a-47fb-a0fb-d8880726b180/1c7d43be-a18a-4567-ac5b-f8a8bd0f7617'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM