Iterating Build Definitions (IBuildDefinition) In TFS – Blocked File Error
When programmatically iterating build definitions in TFS (IBuildDefinition), with code similar to the following (at least, under the same constructs):
- TeamFoundationServer tfsServer = TeamFoundationServerFactory.GetServer(sTFSName);
- IBuildServer buildServer = (IBuildServer)tfsServer.GetService(typeof(IBuildServer));
- IBuildDefinition buildDefinitions = buildServer.QueryBuildDefinitions(sTeamProjectName);
- foreach(IBuildDefinition build in buildDefinitions)
- // do stuff
You may encounter the following error:
The file you are attempting to save or retrieve has been blocked from this Web site by the server administrators.
To get around this problem, you are going to have to pass some credentials into the TeamFoundationServer constructor.
This can either be done with implicit Windows credentials:
- TeamFoundationServer tfsServer = new TeamFoundationServer("http://tfsserver:8080", System.Net.CredentialCache.DefaultCredentials);
or it can be done with explicit credentials:
- TeamFoundationServer tfsServer = new TeamFoundationServer("http:// tfsserver:8080", new NetworkCredential("user", "password", "domain"));