我在 TFS 中有一个编译成 DLL 的 Visual Studio C# 项目。 我需要知道项目中的任何文件是否在一段时间内被修改过。 像这样:
"from date 01/01/2011 to today, check if the project has been modified."
在 C# 中使用 TFS API 执行此操作的最佳方法是什么?
我的想法:从 TFS 获取所有项目项,为每个项目检查它的更改历史记录。根据给定的范围周期过滤历史。如果那个时期有变化,那么那个文件被修改了,因此项目也被改变了。这是正确的吗?
是否可以在一段时间内而不是在一系列变更集中进行相同的搜索?例如:
"from changeset 1071 to latest, check if the project has been modified."
最佳答案
您可以使用 QueryHistory
此类问题的方法:
var tfs = new TfsTeamProjectCollection(new Uri(@"http://tfs.example.com:8080"));
var vc = tfs.GetService<VersionControlServer>();
// DateTime fro, to;
var changesets = from cs in vc.QueryHistory(
"$/YourProject",
VersionSpec.Latest,
0, /* deletion ID, 0 otherwise */
RecursionType.Full,
null, /* user, null for all */
null, /* from changeset, null because these aren't by date */
null, /* to changeset, null because these aren't by date */
Int32.MaxValue, /* get them all */
false, /* just metadata */
false /* just the current stuff */
)
where cs.CreationDate >= fro && cs.CreationDate <= to
select cs;
获得变更集列表后,您可以查询它们以获取与之关联的文件。在这一点上,如果你真的真的想排除误报,我会加上 Roslyn支持读取项目和解决方案并使用它来过滤感兴趣的文件名。
关于c# - 如何检测 TFS 项目源代码已被修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13884733/