So I am attempting to retrieve the files from a workspace in TFS. Unfortunately, every attempt that I have made to do this results in a stalled application. As of right now, this is the code:
public void GetWorkspaceFiles(string workspaceName)
{
VersionControlServer sourceControl = (VersionControlServer)TfsServer.GetService(typeof(VersionControlServer));
var items = sourceControl.GetItems(workspaceName, VersionSpec.Latest, RecursionType.Full)
.Items
.Where(x => x.ItemType == ItemType.File)
.ToList();
for (int x = 0; x < items.Count; x++)
items[x].DownloadFile();
What happens is that every time I run this application (on multiple machines) it stalls on items[x].DownloadFile()
. All the files in TFS are not locked, everything is fine. Attempting to use the Workspace.Get()
method results in the same thing.
If I hit pause, x will be a specific value, but I can't access the items collection, as when I do I get "Cannot evaluate expression because the current thread is in a sleep, wait, or join". When I evaluation the call stack I get:
[In a sleep, wait, or join]
[External Code]
GetWorkspaceFiles(string workspaceName) Line 55
I am at a loss at what to do further. Whenever I pause the application, x
is always at the same value (the value that it stalls on is different for every application run though).
Anyone have any ideas?
Edit: After adding diagnostic logic (based on the link in Grant's answer) I am even more confused than ever.
The workspace I am passing into this method is $/QA/Automated Test Scripts/Regression or System Test Scripts/RDE or Condo
(verified through the debugger).
However, when I look at the tfs logs, it looks to be downloading the code file that I am running, as it says:
02/10/2011 12:26:58 (pid 5808, tid 5968, 42180 ms) Recording OperationStatus.Getting for $/QA/Automated Test Scripts/QA Tools/Test Manager/Test Polling Server/fmMain.cs
Right after that entry is:
02/10/2011 12:26:58 (pid 5808, tid 5968, 42180 ms) DownloadFiles: 18 ms
02/10/2011 12:26:58 (pid 5808, tid 5968, 42181 ms) Acknowledgements: 0 ms
After that there are no further updates to the log file, and my application is stalled. What I am confused about is
1) Why is this trying to pull the application code from TFS when I am specifying a completely different TFS workspace
2) Why is this stalling after attempting to retrieve the file? It's possible that it's because fmMain.cs
is open in Visual Studio, but it should still exception out and not get hung up. I'm able to get latest while the file is open via visual studio normally.
Edit2:
Ok so I was reading through MSDN and I noticed that the workspace name can be the local path to the files. So I modified what I passed in as the workspaceName
parameter to the local directory of the files. I still get stalls, but the log file is a lot less clear on why. I have uploaded the tf.log file here (I have obviously changed proprietary information, such as server and project names, but everything else is untouched). After that last log entry, no further data is written to the log.