I'm using the built in nuget task in VSTS to do a package restore. Our feed is hosted on an internal Artifactory server, and is referenced as a package source in my nuget.config. I'm then using a nuget service endpoint in VSTS to store the credentials to access that feed.
But when I run the build I get the following in the build log, and every request to the nuget feed results in a 401 Unauthorized.
CredentialProvider.TeamBuild: URI Prefixes:
CredentialProvider.TeamBuild:
CredentialProvider.TeamBuild:
CredentialProvider.TeamBuild: URI:
CredentialProvider.TeamBuild: Is retry: False
CredentialProvider.TeamBuild: Matched prefix:
CredentialProvider.TeamBuild: This provider only handles URIs from the build's Team Project Collection
Unauthorized (Id='Microsoft.AspNet.Razor',Version='3.2.3') 16ms
WARNING: Unable to find version '3.2.3' of package 'Microsoft.AspNet.Razor'. The V2 feed at '(Id='Microsoft.AspNet.Razor',Version='3.2.3')' returned an unexpected status code '401 Unauthorized'.Is there anything else I need to configure to get the task to pickup the credentials in the service endpoint? If I just put them as packageSourceCredentials in the nuget.config, it all works fine.
1 Answer
Since the nuget packages feed is located in internal server, you should use the private build agent which can access the URL .
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 "" -username "username" -password "password" -ConfigFile path\to\project\.nuget\nuget.configThen your can commit and push (checkin) the change to remote repo, and build without specifying the nuget service endpoint.
Note:
- Since the packages seems located in
nuget-repos/Package, you should use as feed URL (not ). - Except 401 error message, there also has a warning that shows the package Microsoft.AspNet.Razor 3.2.3 not found. So please also check if the package exist in your feed.