How to call GetWorkspace in TFS properly?

后端 未结 1 1183
粉色の甜心
粉色の甜心 2021-01-18 09:13

Currently when I call GetWorkspace I get ItemNotMappedException exception, but when I iterate over workspaces manually I can get my code working. T

相关标签:
1条回答
  • 2021-01-18 09:45

    The VersionControlServer.GetWorkspace method searches all known workspaces on the current computer to identify a workspace that has explicitly or implicitly mapped the provided local path. If no workspace is found, this method throws an ItemNotMappedException.

    Try to call to Workstation.EnsureUpdateWorkspaceInfoCache in your code to force update the workspace information cache:

    TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("<your-tfs-uri-here>"));
    VersionControlServer tfServer = tpc.GetService<VersionControlServer>();
    Workstation.Current.EnsureUpdateWorkspaceInfoCache(tfServer, tfServer.AuthorizedUser);
    

    Have a look at this similar question: Microsoft.TeamFoundation.VersionControl.Client.ItemNotMappedException even when the workspace exists and has a mapping

    0 讨论(0)
提交回复
热议问题