Connecting to a Team Foundation Server workspace using GetWorkspace

12,644

The problem is that "Test" in your code above refers to the TFS workspace, not the project in TFS. TFS uses an idea called workspaces that you map directories and projects to.

The workspace you are using is shown in the source control explorer windwo towards the top. It says: 'Workspace: ' and then the name of the workspace you are using.

Here is a good resource regarding workspaces: http://www.woodwardweb.com/teamprise/000333.html

You will then need to probably get some folder mappings from TFS as well. The TFS documentaiton is sparse, and much of the work I have done with it requires some trial and error to understand how TFS works, and how the API is different from using the source control explorer in visual studio.

Share:
12,644
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    I am new to Team Foundation Server and I'm trying to connect to a project programmatically using c#. I have the following block of code ...

    string serverName = "http://tfs01:8080";
    TeamFoundationServer tfs = new TeamFoundationServer(serverName);
    VersionControlServer version = (VersionControlServer)tfs.GetService(typeof (VersionControlServer));
    Workspace workspace = version.GetWorkspace("Test", version.AuthenticatedUser);
    MessageBox.Show(workspace.Name);
    

    When I execute the code I receive the following error ...

    TF14061: The workspace Test;vercuskis does not exist.
    

    The "Test" project is off of the root and is visibile from VS 2008 Team Explorer, I do have security access to it and I use it to check in and out code just fine

    I'm not sure if I have the "Test" project referenced correctly within my code. I'm looking for an example of how to reference a project name off of the TFS root.

    Thank you,

  • Admin
    Admin almost 15 years
    Ah ok I see ... well then I guess its not the workspace I'm looking for. I'd like to connect to the project and see all of the items within the source control for that project. I'm guessing I'll have to query the TeamFoundationServer object in order to get into that.