如何在VSTS nuget恢复中为外部nuget提要指定凭据 [英] How to specify credentials for external nuget feeds in VSTS nuget restore

查看:50
本文介绍了如何在VSTS nuget恢复中为外部nuget提要指定凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VSTS中的内置nuget任务来进行软件包还原.我们的feed托管在内部Artifactory服务器上,并在我的nuget.config中作为包源进行引用.然后,我在VSTS中使用nuget服务终结点存储凭据以访问该供稿.

但是当我运行构建时,我会在构建日志中得到以下内容,对nuget feed的每个请求都会导致401未经授权.

  CredentialProvider.TeamBuild:URI前缀:CredentialProvider.TeamBuild:https://ukipo.visualstudio.com/CredentialProvider.TeamBuild:https://ukipo.pkgs.visualstudio.com/CredentialProvider.TeamBuild:URI:http://repo1:8081/artifactory/api/nuget/nuget-reposCredentialProvider.TeamBuild:重试:FalseCredentialProvider.TeamBuild:匹配的前缀:CredentialProvider.TeamBuild:此提供程序仅处理构建的Team Project集合中的URI.未经授权的http://repo1:8081/artifactory/api/nuget/nuget-repos/Packages(Id ='Microsoft.AspNet.Razor',Version ='3.2.3')16毫秒警告:找不到软件包"Microsoft.AspNet.Razor"的版本"3.2.3".http://repo1:8081/artifactory/api/nuget/nuget-repos:位于http://repo1:8081/artifactory/api/nuget/nuget-repos/Packages(Id ='Microsoft.AspNet.Razor',Version ='3.2.3')'返回了意外的状态代码"401未经授权". 

我还需要配置其他内容来获取在服务端点中提取凭证的任务吗?如果我只是将它们作为nuget.config中的 packageSourceCredentials 放置,则一切正常.

解决方案

由于nuget包供稿位于内部服务器中,因此您应使用

选项2:在您的 nuget.config 文件中添加凭据

在本地存储库中,您可以按以下命令将credentical添加到项目级别的 nuget.config 文件中:

  nuget源添加-name"nuget-repos"-源"http://repo1:8081/artifactory/api/nuget/nuget-repos/Packages"-用户名"username"-密码"password"-ConfigFile路径\到\ project \ .nuget \ nuget.config 

然后,您可以提交更改并将其推送(签入)到远程存储库,并在不指定nuget服务终结点的情况下进行构建.

注意:

Since the nuget packages feed is located in internal server, you should use the private build agent which can access the URL http://repo1:8081/artifactory/api/nuget/nuget-repos/Packages.

And there are two options can add the nuget feed credential when you execute NuGet restore task:

Option1: Use nuget service endpoint as you used

You can add Nuget endpoint with Basic Authentication. After enter feed URL, username and password, please also verify the connection before save.

Option2: add credential in your nuget.config file

In your local repo, you can add credentical to your project level nuget.config file as below command:

nuget sources add -name "nuget-repos" -source "http://repo1:8081/artifactory/api/nuget/nuget-repos/Packages" -username "username" -password "password" -ConfigFile path\to\project\.nuget\nuget.config

Then your can commit and push (checkin) the change to remote repo, and build without specifying the nuget service endpoint.

Note:

这篇关于如何在VSTS nuget恢复中为外部nuget提要指定凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆