我如何以编程方式签出的项目为编辑在TFS? [英] How can I programmatically check-out an item for edit in TFS?

查看:276
本文介绍了我如何以编程方式签出的项目为编辑在TFS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的源代码管理下作为一个实用程序处理的文件使用TFS 2010。

I'm working on an utility processing files being under source control using TFS 2010.

如果某个项目尚未签出的编辑,我发现了一个例外,什么是绝对predictable,因为文件是只读模式。

If an item is not yet checked-out for edit, I'm getting an exception, what is definitely predictable because file is in read-only mode.

何种方式退出,以签出文件?

What ways are exited to check-out a file?

P.S。我想要的东西的方案而不是的Process.Start(tf.exe,...); 如果这是适用

P.S. I want something for programmatic rather then Process.Start("tf.exe", "..."); if that's applicable.

推荐答案

一些在这里提到的其他方法仅适用于TFS的某些版本或使用过时的方法。如果您收到一个404,你所使用的方法可能不符合你的服务器版本兼容。

Some of the other approaches mentioned here only work for certain versions of TFS or make use of obsolete methods. If you are receiving a 404, the approach you are using is probably not compatible with your server version.

本办法适用于2005年,2008年,和2010年我不使用任何更长的时间,所以我没有测试2013。

This approach works on 2005, 2008, and 2010. I don't use it any longer, so I haven't tested 2013.

var workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(fileName);
using (var server = new TfsTeamProjectCollection(workspaceInfo.ServerUri))
{
    var workspace = workspaceInfo.GetWorkspace(server);    
    workspace.PendEdit(fileName);
}

这篇关于我如何以编程方式签出的项目为编辑在TFS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆