简体   繁体   English

由于 Nuget 工件源上的 URL 格式错误,Azure DevOps dotnet 还原任务失败

[英]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:我在 YML 文件中有以下恢复任务:

- 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但是由于错误的提要 URL 导致恢复操作失败,日志中显示如下: https://pkgs.dev.azure.com/<organization_name>/_packaging/MyFeedName/nuget/v3/index.json ://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根据来自 DevOps 的“连接到 feed”信息,URL 应该采用以下格式: https://pkgs.dev.azure.com/<organization_name>/<guid>/_packaging/MyFeedName/nuget/v3/index.json ://pkgs.dev.azure.com/<organization_name>/<guid>/_packaging/MyFeedName/nuget/v3/ 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.所以,它似乎没有插入导致它失败的<guid>部分。 I can't figure out how to configure the task in YAML, such that it uses the right URL.我不知道如何在 YAML 中配置任务,以便它使用正确的 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.我不知道如何在 YAML 中配置任务,以便它使用正确的 URL。 How do I do this?我该怎么做呢?

This <guid> is the id of your current project.这个<guid>是你当前项目的 id。 When you add this DotNetCoreCLI@2 task to your yml file, the vstsFeed 's value should be like this format: {projectid}/{feedid} .当您将此DotNetCoreCLI@2任务添加到 yml 文件时, vstsFeed的值应类似于以下格式: {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 .如果您不知道如何获取ProjectId ,请参阅 Rest Api 文档: Projects - List

You can call it in Postman, like below:您可以在 Postman 中调用它,如下所示:

在此处输入图像描述

Or, you can directly use the Feed Management - Get Feeds to get both your project id and feed id at the same time:或者,您可以直接使用Feed 管理 - 获取 Feed同时获取您的项目 id 和 Feed id:

在此处输入图像描述

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 . vstsFeed期待{projectid}/{feedid} ,而不是完整的提要 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.这些 id 是 GUID,可以使用以下步骤找到。

In Azure DevOps open your project, select Artifacts, select the feed you want from the dropdown and clicking on the 'Connect to Feed' button.在 Azure DevOps 中打开您的项目,选择 Artifacts,从下拉列表中选择所需的源,然后单击“连接到源”按钮。 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.然后选择 Visual Studio,复制机器设置源 URL 并输入 URL https://pkgs.dev.azure.com/{Organization Name}/{Project Name}/_packaging/{Feed Name}/nuget/v3/index.json到你的浏览器。

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.您可以将生成的 JSON 复制并粘贴到 Visual Studio Code 中的新文件中,然后按 Alt-Shift-F 进行格式化,或者使用JSON Formatter for Edge等浏览器扩展来使 JSON 清晰易读。

Anyone of the URLs provided in the resources contain the project id (first GUID) and the feed id (second GUID).资源中提供的任何 URL 都包含项目 ID(第一个 GUID)和提要 ID(第二个 GUID)。 For example from the URL…例如从 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.您可以将以下 YMAL 添加到您的构建管道中。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Nuget 恢复在 Azure Devops 中无法使用工件提要 - Nuget restore not working with artifact feed in Azure Devops 使用私有包源在 Azure DevOps 中构建的 Dotnet 无法从私有 nuget 源恢复 - Dotnet build in Azure DevOps with private package source cannot restore from private nuget feed Azure DevOps Pipeline 上的 Nuget 还原失败 - Nuget Restore fails on Azure DevOps Pipeline 使用 Azure DevOps Artifact 时无法在 Build Pipeline 中执行“dotnet tool restore --interactive” - Fail to execute "dotnet tool restore --interactive" in Build Pipeline when using Azure DevOps Artifact 如何正确设置dotnet核心类库以在Azure DevOps中发布到NuGet feed? - How do you properly set up a dotnet core class libray to publish to NuGet feed in Azure DevOps? 私有nuget包的dotnet恢复失败 - dotnet restore fails for private nuget packages Docker do.net 恢复私人提要失败 - Docker dotnet restore private feed fails dotnet restore 在错误的 nuget-source 中查找 - dotnet restore looking in wrong nuget-source 当混合私人nuget feed和NEST时,dotnet恢复失败 - dotnet restore failing when mixing private nuget feed and NEST Nuget 在 Azure Devops 上恢复失败,并显示消息“无法加载源的服务索引” - Nuget restore fails on Azure Devops with message "unable to load the service index for source"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM