[英]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.