2013-08-29 24 views
0

我使用批處理腳本自動獲取和編譯多個解決方案。以下是批處理文件中的示例代碼片段:Team Foundation Server的批處理腳本Get方法在通過程序調用時會引發錯誤

"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'.

回答