locked
TFS API - Project Source Explorer URL RRS feed

  • Question

  • I'm working on WPF application, which is using Microsoft.TeamFoundationServer.ExtendedClient NuGet package to connect to TFS API. Can anyone provide me code example where i can get source explorer url for particular project? Something like this: http://tfs-server:8080/tfs/project-collection/project-name/_versioncontrol

    Currently I got something like this:

    {
    string serverItemPath = "";
    TswaClientHyperlinkService service = Server.GetService<TswaClientHyperlinkService>();
    return service.GetSourceExplorerUrl(serverItemPath);
    }

    But I don't know what to assign to serverItemPath. In this case I'm only getting exception:

    System.InvalidOperationException: CollectionId is not initialized.

    Maybe there is other way?

    Saturday, August 20, 2016 8:55 AM

Answers

  • Hi JeanPA,

    Thank you for posting here.

    The serverItemPath parameter is the server path for files in your team project. Here is an example: "$/TeamProjectName/Folder1".

    So if your want to get a Source Explorer URL for a team project:

    string serverItemPath = "$/TeamProject1";
    TfsTeamProjectCollection server = new TfsTeamProjectCollection(new Uri("http://serverName:8080/tfs/DefaultCollection"));
    TswaClientHyperlinkService service = server.GetService<TswaClientHyperlinkService>();
                
    System.Uri PATH = service.GetSourceExplorerUrl(serverItemPath);


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Tingting MOModerator Wednesday, August 24, 2016 2:09 AM
    • Marked as answer by JeanPA Wednesday, August 24, 2016 7:12 AM
    Monday, August 22, 2016 8:48 AM
    Moderator