Azure Pipeline中Dotnet Restore失败:无法加载私有NuGet源服务索引
问题:Azure Pipeline执行dotnet restore时遇NU1301错误,无法加载私有源服务索引
执行dotnet restore时触发NU1301错误,提示无法加载私有源myPrivateFeedUrl的服务索引,但此前系统已明确匹配到包源映射:
Package source mapping matches found for package ID 'myPrivatePackage' are: 'myPrivateFeed'
该问题同时出现在部署于虚拟机的TFS环境,以及另一台机器上的Azure自托管代理中。
Pipeline YAML配置
pool: name: 'pool' variables: solution: '**/*.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' steps: - task: CmdLine@2 inputs: script: | cd $(Agent.BuildDirectory)/s/AppName.App/ dir dotnet restore --verbosity diagnostic env: HTTPS_PROXY: "corporate proxy here" NO_PROXY: "proxy exceptions here" - task: DotNetCoreCLI@2 displayName: 'Build Solution' inputs: command: 'build' projects: '**/project.csproj'
nuget.config配置
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <clear /> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> <add key="privateFeed" value="privateFeedUrl" /> </packageSources> <packageSourceMapping> <packageSource key="nuget.org"> <package pattern="*" /> </packageSource> <packageSource key="privateFeed"> <package pattern="privatePackagePrefix.*" /> </packageSource> </packageSourceMapping> </configuration>
已尝试但未解决的方案
- 添加企业代理配置
- 向代理机器安装所需证书
- 禁用管道权限限制选项:
- 针对非发布管道将作业授权范围限制为当前项目
- 针对发布管道将作业授权范围限制为当前项目
- 在代理工作文件夹内手动执行
dotnet restore(可立即成功) - 在
dotnet restore步骤前添加NuGet身份验证任务
补充说明:已确认私有源的权限配置正常
内容的提问来源于stack exchange,提问作者Vasco Santos
相关产品推荐
相关产品推荐

