我想通过编码找出给定的Team Project是否有关联的SharePoint。如果是,我还想获取SharePoint的URL,以便创建指向它的特定链接。
我不是指TFS的Web访问,而是关联的SharePoint。有没有办法在不知道与TFS服务器不同的SharePoint服务器的URL的情况下找到它?
答案 0 :(得分:6)
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;
}