Reputation: 4063
We have implemented a CI process on TFS. First step of this CI process is Nuget Restore.
The Project has some dependency which are stored on a nuget feed on same TFS instance. During restore 401 authorization required error occures.
2017-08-22T14:45:56.9497847Z [command]d:\path\3.5.0\NuGet.exe restore
-NonInteractive D:\somepath\project.sln -Verbosity Detailed
2017-08-22T14:46:03.5127467Z Error downloading 'dependency.4.1.1' from 'http://URL:80/tfs/TFSCollection/_packaging/path/dependency.4.121.1.nupkg'.
2017-08-22T14:46:03.5127467Z Response status code does not indicate success: 401 (Unauthorized).
But when I try same command which is displaed on the logs from command line. Dependencies are being installed succesfully.
I have checked there is a nupkg here:
'http://URL:80/tfs/TFSCollection/_packaging/path/dependency.4.121.1.nupkg'
I have checked following command runs succesfully from commandline on same machine.
d:\path\3.5.0\NuGet.exe restore
-NonInteractive D:\somepath\project.sln -Verbosity Detailed
We are planning to open a ticket to Microsoft. But, It seems to me there is a simple trick which we could not see. Do you have any such experience. Why same command Works from command line but not working from TFS. Do you have any idea?
Upvotes: 0
Views: 415
Reputation: 30372
It should be the authorization issue according to the error message "401 (Unauthorized)"
Please check the NuGet.Config file on your agent machine, commonly it should be located in C:\Users\{user}\AppData\Roaming\NuGet
, make sure you have add the custom feed and set the packageSourceCredentials
for the feed.
Please see below articles for more information:
UPDATE:
According to the official documents, you have to set the credentials for the custom feed. With the command below it will store the credentials in Nuget.config file. For now, there isn't a way without putting credentials to configuration file
With UserName/Password:
nuget sources add -name {your feed name} -source {your feed URL} -username {your domain username} -password {your domain password}
With PAT: (Mentioned in the second link above). See this link for how to generate PAT
nuget.exe sources add -name {your feed name} -source {your feed URL} -username {anything} -password {your PAT}
Upvotes: 1