I want to get the URL of the web access Page for a specific TeamProject.
I found some samples using a TswaClientHyperlinkService object calling GetHomeUrl(new Uri("MyprojectName")), but I was not able to provide a correct Uri value for that. Maybe I did not understand how to format the parameter..
I know how to get the base url for the webaccess, but I want to get to the page for a specific Team Project within a specifc Team Project Collection.
It turns out that the GetHomeUrl
method expects a vsts://
url, not the url to the project collection you'd normally use. The following code can be used to get the Uri:
var server = TfsConfigurationServerFactory.GetConfigurationServer(new Uri("http://localhost:8080/tfs" /* your tfs uri here */));
server.Authenticate();
var service = server.GetService<TswaClientHyperlinkService>();
var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://localhost:8080/tfs/DefaultCollection"));
var cssService = projectCollection.GetService<ICommonStructureService3>();
var project = cssService.GetProjectFromName(/*YourProjectNameHere*/);
var home = service.GetHomeUrl(new Uri(project.Uri));