Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the SharePoint URL for a Team Project programmatically

Tags:

tfs

sharepoint

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?

like image 638
ulfgebhardt Avatar asked Nov 06 '12 12:11

ulfgebhardt


1 Answers

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;
}
like image 184
Rolf Huisman Avatar answered Oct 07 '22 17:10

Rolf Huisman