我在我的C#代码中使用tf.exe来在TFS中创建新分支。我的操作步骤如下:
public static bool TFBranch(string projectPath, string originName, string branchName)
{
string branchedProject = projectPath + "\\" + branchName;
string projectToBranch = projectPath + "\\" + originName;
string path = Environment.ExpandEnvironmentVariables(@"branch " + projectToBranch + " " + branchedProject);
path = path.Replace("\\", "/");
return ExecuteProcess(path);
}
private static bool ExecuteProcess(string path)
{
MyProcess proc = new MyProcess();
var currentDirectory = WorkspaceHandler.GetLocalWorkspace();
var command = @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\tf.exe";
Directory.SetCurrentDirectory(currentDirectory);
proc.FileName = command;
proc.Arguments = path;
try
{
proc.Execute();
}
catch (Exception e)
{
_Logger.Error("Could not execute TF.exe. Exception: " + e.ToString());
return false;
}
return true;
}
大部分工作都如我所期望的那样运行。我从一个已经包含分支的目录中创建一个分支,因此新的分支也包含一个分支。但有时tf.exe会创建一个文件夹而不是一个分支。这是tf.exe的错误还是我做错了什么?
例如:
以下是一个分支命令的样子:
-- 编辑 --
以下是我手动操作的步骤:
- 使用菜单进入模板/分支源/文件夹/主文件夹:
- 在对话框中定义“目标分支名称”:
- 结果与我预期得到的相同: