0

I created custom build activity in my TFS build template. In that custom activity I added some code which purpose is to connect to TFS read last build number, create custom number and set new number to TFS.

To connect to TFS I am using following code:

NetworkCredential netCred = new NetworkCredential("username", "password");           
TfsTeamProjectCollection server = new TfsTeamProjectCollection(new Uri("https://someproject.visualstudio.com/DefaultCollection")), netCred);
server.Authenticate();

That code works properly when I tried to execute from my local computer in some sample console application. But when I tried to execute that code during TFS build it throw exception.

kat1330
  • 5,134
  • 7
  • 38
  • 61
  • can you compare your access rights to the build machine rights .. sounds like a permissions issue and or user account / service account issue.. do you have a system admin on staff where you are currently working check this previous posting for some hints as well http://stackoverflow.com/questions/12685111/error-tf30063-you-are-not-authorized-to-access-defaultcollection – MethodMan May 26 '15 at 17:25
  • I am using administrator account in this case. These credentials work for from sample app. I am not sure why I have permission issues! – kat1330 May 26 '15 at 17:58
  • the number one misconception with most developers is that just because it works or things work on your local machine and or environment, that they will automatically work the same in the target environment .. so I can only assume that there's a permission issue – MethodMan May 26 '15 at 18:00

1 Answers1

0

You don't need authentication: the build is running with high privileges with respect to TFS access.

Giulio Vian
  • 8,248
  • 2
  • 33
  • 41
  • This is exactly what I don't understand. When I tried in my local without authentication (but I was logged in TFS) it works. But when I tried like this TfsTeamProjectCollection server = new TfsTeamProjectCollection(new Uri("https://someproject.visualstudio.com/DefaultCollection")); whit custom build activity in TFS it doesn't work. – kat1330 May 29 '15 at 07:23