6
votes

I want to find out by coding if a given Team Project has an associated SharePoint. If yes I also want to get the URL for the SharePoint in order to create a specific link to it.

I do not mean the web access of the TFS but the associated SharePoint. Is there a way to find this out without knowing the URL of the SharePoint server that is different from the TFS server?

1

1 Answers

6
votes
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Server;

private static string RetrieveProjectPortalBaseAddress(TfsTeamProjectCollection tfs, string teamProject)
{
   IRegistration registration = (IRegistration)tfs.GetService(typeof(IRegistration));
   RegistrationEntry[] entries = registration.GetRegistrationEntries("TeamProjects");
   ServiceInterface endpoint = entries[0].ServiceInterfaces.FirstOrDefault(si => si.Name == teamProject + ":Portal");
   return endpoint.Url;
}