TFS API: GetLocalWorkspaceInfo always returns null

前端 未结 8 1305
無奈伤痛
無奈伤痛 2020-12-24 06:46

On one of my machines, I get a return value of null from any GetLocalWorkspaceInfo call. I have isolated to problem to where it even fails for this simple progr

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 07:15

    This is how to find workspace when you have server path:

      Workspace[] workspaces = _versionControl.QueryWorkspaces(null, Environment.UserName, Environment.MachineName);
      return workspaces.FirstOrDefault(w => !string.IsNullOrEmpty(w.TryGetLocalItemForServerItem(ConstDefaultFlowsTfsPath)));
    

    Where ConstDefaultFlowsTfsPath is server path with "$" for instance : "$/MyCompany/Services/DiagnosticsFlows"

    You could also replace the last line to:

    return workspaces.FirstOrDefault(w => !string.IsNullOrEmpty(w.GetServerItemForLocalItem(myLocalPath)));
    

    and that should work for you too.

提交回复
热议问题