Connect to a Team Foundation Server workspace using GetWorkspace

I'm new to Team Foundation Server, and I'm trying to connect to a project programmatically using C #. I have the following code 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 get the following error ...

TF14061: The workspace Test;vercuskis does not exist.

The Test project is disconnected from the root and is visible from VS Team Team Explorer, I have access to security and I use it to verify and delete the code just fine

I am not sure if I have a Test project that is correctly specified in my code. I am looking for an example of how to refer to the project name from the root of TFS.

Thanks,

+3
source share
3 answers

, "" TFS, TFS. TFS , , .

, , windwo . : " :", , .

: http://www.woodwardweb.com/teamprise/000333.html

, , TFS. TFS documentaiton , , , , , TFS, API visual studio.

+6

, , . : http://www.woodwardweb.com/teamprise/000333.html

, / , . VersionControlServer.

  • QueryItems = "tf dir"
  • QueryItemsExtended = "tf properties"
  • QueryPendingChanges = "tf status"
  • QueryHistory = "tf history" - , yield return
  • ..
0

, , , WorkSpace VS . WorkSpace .

: CMD VS : tf workspace /new /s:http://tfs2010.server.com:8080/tfs

:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>tf workspace /new /s:http://tfs2010.server.com:8080/tfs

: : , ( char) : $/FolderName : C:\FolderName

    this._server = config.GetAttribute("server");
    **this._workspace = config.GetAttribute("workspace");**
    this._user = config.GetAttribute("user");
    this._password = config.GetAttribute("psw");
    TeamFoundationServer tfs = new TeamFoundationServer(this._server, new System.Net.NetworkCredential(this._user, this._password));
    tfs.Authenticate();
    VersionControlServer versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
    Workspace ws = versionControl.GetWorkspace(this._workspace, this._user);
0

Source: https://habr.com/ru/post/1712558/


All Articles