c# - GetLocalWorkspaceInfo always get null -
my problem similar tfs api: getlocalworkspaceinfo returns null, except using visual studio 2015, answers don't work me. , tried getalllocalworkspaceinfo, returns null well.
thanks
i have tested code snippet referred in vs 2015 , got successful result. make sure have reference dlls in vs 2015: c:\program files (x86)\microsoft visual studio 14.0\common7\ide\commonextensions\microsoft\teamfoundation\team explorer
and in code snippet, need use console.writeline
output workspace information want:
private static workspace findworkspacebypath(tfsteamprojectcollection tfs, string workspacepath) { versioncontrolserver versioncontrol = tfs.getservice<versioncontrolserver>(); workspaceinfo workspaceinfo = workstation.current.getlocalworkspaceinfo(workspacepath); if (workspaceinfo != null) { console.writeline(workspaceinfo.computer); console.writeline(workspaceinfo.displayname); return versioncontrol.getworkspace(workspaceinfo); } //no workspace found using method 1, try query workspaces user has on machine. workspace[] workspaces = versioncontrol.queryworkspaces(null, environment.username, environment.machinename); foreach (workspace w in workspaces) { foreach (workingfolder f in w.folders) { if (f.localitem.equals(workspacepath)) { return w; } } } throw new exception(string.format("tfs workspace cannot determined {0}.", workspacepath)); }
Comments
Post a Comment