我使用批处理脚本来自动获取和编译几个解决方案。这是批处理文件中的示例片段:
"C:\...\IDE\TF.exe" get $/NG3rdParty/Main /recursive
当我从命令提示符调用它时,这工作正常。但是,我正在编写一个 C# 程序来更改 DLL 的版本号,它执行以下操作:
var businessFile= @"C:\Build\Common.AssemblyInfo.cs";
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(@"http://tfs:8080"));
var workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(businessFile);
var workspace = workspaceInfo.GetWorkspace(tfs);
workspace.PendEdit(businessFile);
var batchFilePath = @"\CleanBuild.bat";
var batchFile = path + batchFilePath;
var p = new Process
{
StartInfo =
{
FileName = batchFile,
UseShellExecute = true
}
};
p.Start();
p.WaitForExit();
当从程序调用批处理文件时,同一行将引发此异常:
Unable to determine the workspace. You may be able to correct this by running 'tf workspaces /collection:TeamProjectCollectionUrl'.