gpt4 book ai didi

.net-core - Nuget 还原不适用于 Azure Devops 中的工件源

转载 作者:行者123 更新时间:2023-12-04 00:57:16 25 4
gpt4 key购买 nike

NuGet 还原从同一组织中的另一个项目的提要失败 404。

当使用管道中的 nuget restore 时,找不到不同项目中的提要。

最佳答案

经过长时间的搜索,这些是使其一致工作所必需的步骤:

设置权限

  • 确保消费项目禁用了此设置
  • 项目设置(左下角)--> 管道 --> 设置 --> 将作业授权范围限制为当前项目(由另一个 answer 提供)
  • 确保将消费项目的 Build Service 添加到 feed
  • 的权限中

    设置构建管道
  • 使用 .Net Core CLI Task
  • 理想情况下,您将使用 nuget.config file 并确保在
  • 中检查它
  • feedsToUse 设置为 'config'

  • azure-pipelines.yml

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

    配置文件

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

    无需向管道添加身份验证任务,因为 dotnet 命令会自行执行此操作...但是:

    Most dotnet commands, including build, publish, and test include an implicit restore step. This will fail against authenticated feeds, even if you ran a successful dotnet restore in an earlier step, because the earlier step will have cleaned up the credentials it used.
    - Source (.NET Core CLI task docs)

    关于.net-core - Nuget 还原不适用于 Azure Devops 中的工件源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61384798/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com