2009-08-15 54 views

回答

7

您可以使用命令腳本使用tf workspace命令創建工作區。然後,您可以使用tf workfold命令映射工作文件夾。工作區命令有一個/模板選項

例如:

創建工作區的人

tf workspace /new Beta1;jenh 

然後創建基於模板的一個新

tf workspace /new /template:Beta1;jenh /server:teamserver2 Beta1;user2 

映射一個文件夾:

tf workfold /map $/projects/project_one C:\localproject1 /workspace:Beta1;user2 
+1

+1很好的總結。 – 2009-08-15 20:17:37

+1

我唯一需要注意的是,你不能在模板引用的機器上這樣做,因爲你得到一個文件夾已經映射的錯誤。 – 2009-08-17 08:47:49

+0

是的,因爲您只能將一個工作區中的一個文件夾放入一臺機器 – 2009-08-18 09:46:39

0

您還可以將工作區映射從一個工作區複製並粘貼到另一個工作區。

  1. 編輯模板工作區。
  2. 選擇您想要複製的映射。
  3. 按Ctrl + C
  4. 創建一個新的工作區(或編輯現有的)
  5. 標籤到工作文件夾網格。
  6. 按Ctrl + V

您也可以映射粘貼到記事本,更新他們,複製並粘貼回到工作區中編輯。

,你會在記事本中看到的格式: :

例: $/TeamProj1 /中繼線/ C:\ TFS \ WorkingFolder \

2

根據多少細粒度控制,你想對這個過程中,我發現這個PowerShell腳本是有效的:這種方法的http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.createworkspaceparameters.aspx一個優勢tf.exe是:

"Microsoft.TeamFoundation.Client", 
"Microsoft.TeamFoundation.VersionControl.Common", 
"Microsoft.TeamFoundation.VersionControl.Client" | 
    ForEach-Object { Add-Type -AssemblyName "$_, Version=11.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a" } 

$tfsUrl = "http://tfsserver:8080/collection" 

$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($tfsUrl) 
$vcs = $tfs.GetService([type]"Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer") 

$workspaceParameters = New-Object Microsoft.TeamFoundation.VersionControl.Client.CreateWorkspaceParameters -ArgumentList "WorkspaceName" 

# Add any specific parameters that you want according to http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.createworkspaceparameters.aspx 
# e.g. $workspaceParameters.Comment = "" 
# e.g. $workspaceParameters.Computer = "" 
# e.g. $workspaceParameters.Location = [Microsoft.TeamFoundation.VersionControl.Common.WorkspaceLocation]::Local 

$workspace = $vcs.CreateWorkspace($workspaceParameters) 

# Add any working folders that you would defined below 
# e.g. $workspace.Map("$/", "C:\ProjectDirectory") 

所有這一切能夠被定義爲MSDN文章中列表中的參數您可以明確定義工作區位置(即服務器或本地),並且對創建時定義的映射有更多的控制權。

你應該能夠調整適當的設置並將這些代碼轉儲到任何* .ps1文件中。

0

月開始做修改此F#腳本什麼:

/// 
/// Creates new local TFS workspace for specified folder and branch conventionally naming locals with server names 
/// 
// Install Team Explorer 
#r "Microsoft.TeamFoundation.Client" 
#r "Microsoft.TeamFoundation.VersionControl.Common" 
#r "Microsoft.TeamFoundation.VersionControl.Client" 

open Microsoft.TeamFoundation.VersionControl 
open Microsoft.TeamFoundation.VersionControl.Common 
open Microsoft.TeamFoundation.VersionControl.Client 
open Microsoft.TeamFoundation.Client 

//change these 
let tfsUrl = "http://tfsserver:8080/collection" 
let branch ="dev_features" 
let folder = "/FeaturesProject/" 


//conventions 
let workspaceName = System.Environment.MachineName+"_"+branch 
let localFolder = "D:"+folder+branch 
let serverFolder = "$/"+folder+branch 

// actions 
let tfs = TeamFoundationServerFactory.GetServer(tfsUrl) 
let vcs = tfs.GetService<VersionControlServer>() 
let workspaceParameters = Client.CreateWorkspaceParameters(workspaceName) 
workspaceParameters.Folders <- [| WorkingFolder(serverFolder,localFolder) |] 
workspaceParameters.Location <- System.Nullable<WorkspaceLocation>(WorkspaceLocation.Local) 
let workspace = vcs.CreateWorkspace(workspaceParameters) 

//run 
workspace |> ignore