简体   繁体   English

Nuget 恢复在 Azure Devops 中无法使用工件提要

[英]Nuget restore not working with artifact feed in Azure Devops

NuGet restore fails 404 from feed on another project in same organization. NuGet 从同一组织中的另一个项目上恢复失败 404。

When using nuget restore from a pipeline the feed inside a different project is not found.使用nuget restore时,找不到不同项目中的提要。

After searching for a long time, these are the steps necessary to make it work consistently:经过长时间的搜索,这些是使其始终如一地工作所必需的步骤:

Setup permissions设置权限

  • Make sure to add Build Service of the consuming project to the permissions of the feed确保将消费项目的构建服务添加到提要的权限
  • Make sure the consuming project has these two settings disabled确保消费项目禁用了这两个设置
    • Project settings (bottom left) --> Pipelines --> Settings项目设置(左下)--> Pipelines --> Settings
      • Limit job authorization scope to current project for non-release pipelines将作业授权 scope 限制为非发布管道的当前项目
      • Limit job authorization scope to current project for release pipelines将作业授权 scope 限制为发布管道的当前项目

Setup build pipeline设置构建管道

  • Use the .Net Core CLI Task使用.Net Core CLI 任务
  • Ideally you would use a nuget.config file and make sure to check it in理想情况下,您将使用nuget.config file并确保将其签入
  • Set the feedsToUse to 'config'feedsToUse设置为'config'

azure-pipelines.yml azure-pipelines.yml

- task: DotNetCoreCLI@2
      displayName: DotNetCore-Restore
      inputs:
        command: 'restore'
        projects: '$(PathToSolution)'
        feedsToUse: 'config'
        nugetConfigPath: '$(PathToNugetConfig)/nuget.config'
        includeNuGetOrg: true

nuget.config nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="feed_name" value="feed_url" />
  </packageSources>
</configuration>

There is no need to add an authenticate task to the pipeline as the do.net command does this by itself... However:不需要向管道添加身份验证任务,因为 do.net 命令会自行执行此操作......但是:

Most do.net commands, including build, publish, and test include an implicit restore step.大多数 do.net 命令,包括构建、发布和测试,都包含一个隐式恢复步骤。 This will fail against authenticated feeds, even if you ran a successful do.net restore in an earlier step, because the earlier step will have cleaned up the credentials it used.即使您在前面的步骤中成功运行了 do.net 还原,这对于经过身份验证的提要也会失败,因为前面的步骤已经清除了它使用的凭据。

You can refer to this doc to setup Azure Artifacts Credential Provider for usage across various tooling.您可以参考文档来设置 Azure Artifacts Credential Provider,以便在各种工具中使用。

暂无
暂无

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

相关问题 由于 Nuget 工件源上的 URL 格式错误,Azure DevOps dotnet 还原任务失败 - Azure DevOps dotnet restore task fails due to wrong URL format on Nuget artifact feed 使用私有包源在 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 管道中的本地提要恢复 package - Strange behavior restore package from local feed in 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 Azure DevOps YAML-.Net Core CLI无法使用内部工件提要打包 - Azure DevOps YAML - .Net Core CLI can't pack using internal artifact feed Nuget 在 Azure Devops 上恢复失败,并显示消息“无法加载源的服务索引” - Nuget restore fails on Azure Devops with message "unable to load the service index for source" 如何正确设置dotnet核心类库以在Azure DevOps中发布到NuGet feed? - How do you properly set up a dotnet core class libray to publish to NuGet feed in Azure DevOps? Azure 提要:找不到 nuget 包 - Azure feed: nuget package is not found Azure 神器 Nuget package 调试问题 - Azure Artifact Nuget package debugging issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM