C# TFS API“没有工作文件夹 C:\TFS”在VS2008安装的系统中
我想找出最近使用 C# 和 TFS2010 中的 TFS API 签入的文件。在安装了 MS Visual studio 2010 的地方它工作得很好。这是使用VS2010、.Net 3.5开发的。
当我在安装了 VS2008 的系统中使用此 exe 时,会抛出错误“*没有工作文件夹 C:\TFS”*。
- 本系统只有3.5 Framework。
- 我从 C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0 复制了所有文件以及可执行文件。
- C:\TFS 是实际的映射文件夹。甚至还尝试了内部文件夹。
请提出任何建议。 有没有办法在不考虑本地映射的情况下从 TFS 获取结果?
TeamFoundationServer tfsServer = new TeamFoundationServer("http://snchndevtfsapp:8080/tfs/defaultcollection");
WorkItemStore workItemStore = new WorkItemStore(tfsServer);
VersionControlServer vcServer = tfsServer.GetService(typeof(VersionControlServer)) as VersionControlServer;
var usersWorkspaces = vcServer.QueryWorkspaces(null, vcServer.AuthorizedUser, Environment.MachineName).ToList();
List<ChangedTFSItem> foundPastChanges = new System.Collections.Generic.List<ChangedTFSItem>();
var allPastChangesets = vcServer.QueryHistory(@"C:\TFS",
VersionSpec.Latest,
0,
RecursionType.Full,
null,
null,
null,
1000,
true,
false).Cast<Changeset>();
//.Where(x => x.Committer.Contains(Environment.UserName));
List<ChangedTFSItem> _foundPastChanges = allPastChangesets
.SelectMany(x => x.Changes)
.Where(x => x.Item.CheckinDate.Date >= ((DateTime)dateEdit1.EditValue))
//.DistinctBy(x => x.Item.ServerItem, x => x.Item.ServerItem.GetHashCode())
.Select(x => new ChangedTFSItem()
{
FileName = Path.GetFileName(x.Item.ServerItem),
ServerItem = usersWorkspaces[0].GetLocalItemForServerItem(x.Item.ServerItem).Replace(textEdit1.Text, ""),
LocalPath = usersWorkspaces[0].GetLocalItemForServerItem(x.Item.ServerItem),
ChangeTypeName = x.ChangeType.ToString(),
ChangeDate = x.Item.CheckinDate.ToString()
}).ToList();
I want to find out the files recently checked in using C# and TFS API from TFS2010. It works fine where MS Visual studio 2010 is installed. this is developed using VS2010, .Net 3.5.
When I use this exe in system having VS2008 installed throws error as "*There is no working folder C:\TFS"*.
- This system has only 3.5 Framework.
- I copied all the files from C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0 along with executable.
- C:\TFS is the actual mapping folder. Even tried inner folder as well.
any suggestion please. is there any way to get result from TFS without considering local mappings?
TeamFoundationServer tfsServer = new TeamFoundationServer("http://snchndevtfsapp:8080/tfs/defaultcollection");
WorkItemStore workItemStore = new WorkItemStore(tfsServer);
VersionControlServer vcServer = tfsServer.GetService(typeof(VersionControlServer)) as VersionControlServer;
var usersWorkspaces = vcServer.QueryWorkspaces(null, vcServer.AuthorizedUser, Environment.MachineName).ToList();
List<ChangedTFSItem> foundPastChanges = new System.Collections.Generic.List<ChangedTFSItem>();
var allPastChangesets = vcServer.QueryHistory(@"C:\TFS",
VersionSpec.Latest,
0,
RecursionType.Full,
null,
null,
null,
1000,
true,
false).Cast<Changeset>();
//.Where(x => x.Committer.Contains(Environment.UserName));
List<ChangedTFSItem> _foundPastChanges = allPastChangesets
.SelectMany(x => x.Changes)
.Where(x => x.Item.CheckinDate.Date >= ((DateTime)dateEdit1.EditValue))
//.DistinctBy(x => x.Item.ServerItem, x => x.Item.ServerItem.GetHashCode())
.Select(x => new ChangedTFSItem()
{
FileName = Path.GetFileName(x.Item.ServerItem),
ServerItem = usersWorkspaces[0].GetLocalItemForServerItem(x.Item.ServerItem).Replace(textEdit1.Text, ""),
LocalPath = usersWorkspaces[0].GetLocalItemForServerItem(x.Item.ServerItem),
ChangeTypeName = x.ChangeType.ToString(),
ChangeDate = x.Item.CheckinDate.ToString()
}).ToList();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要将物理路径作为查询历史记录
@"C:\TFS"
中的第一个参数,而是尝试使用源代码管理路径。如果对所有变更集感兴趣,只需放置根"$/"
。对于您想要完成的任务,您可以通过执行以下操作来跳过任何本地工作区连接:
但随后您将检索已更改模块的服务器路径,而不是它们在工作站中映射的位置。
最后一点:您必须使用
includeChanges
=true
来查询历史记录,因此请求最后的1000
变更集应该相当昂贵。Instead of placing a physical path as your first argument in Query History
@"C:\TFS"
, try using a source control path. If are interested in all changesets, simply place the root"$/"
.For the task you are trying to accomplish, you can skip any local workspace connection by doing something like this:
but then you 'll retrieve the server paths for the changed modules and not where they have been mapped in your workstation.
One final remark: You have to QueryHistory with
includeChanges
=true
, therefore asking for the last1000
changesets should be rather expensive.