You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps中nuget.config报错NU1301的问题求助

Azure DevOps NuGet还原任务NU1301错误求助

场景说明

  • 已为分支设置策略,用于自动执行还原、构建和测试任务
  • 采用Azure DevOps Artifacts服务管理多个私有NuGet源
  • 存在两个.NET 7项目:Project A通过nuget.config引用Project B
  • 创建拉取请求(PR)时,构建验证触发后抛出NU1301错误

错误信息

D:\a\1\s\[NAME PROJECT].csproj : error NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/[PRIVATE FEED]/nuget/v3/index.json.

流水线还原任务配置

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: '**/*.csproj'
    feedsToUse: config
    nugetConfigPath: nuget.config

nuget.config内容

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <packageRestore>
    <add key="enabled" value="true" />
    <add key="automatic" value="true" />
  </packageRestore>
  <packageSources>
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="[PRIVATE FEED]" value="https://pkgs.dev.azure.com/[PRIVATE FEED]/nuget/v3/index.json" />
  </packageSources>
  <apikeys>
    <add key="https://pkgs.dev.azure.com/[PRIVATE FEED]/nuget/v3/index.json" value="[PRIVATE APIKEY]" />
  </apikeys>
</configuration>

已尝试的解决方案(均无效)

  • 在nuget.config中配置私有源APIKEY
  • 在nuget.config中使用个人账号的Basic Auth认证信息
  • 在Azure DevOps「项目设置→流水线→服务连接」中创建对应的服务连接
  • 将Azure DevOps「项目设置→设置→限制发布流水线的作业授权范围为当前项目」设置为false

恳请帮忙解决此问题,让还原任务能正确读取nuget.config并完成私有源的包还原。

内容的提问来源于stack exchange,提问作者Danillo Parreira

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 08:34:15