有没有办法根据预先存在的“模板”轻松创建工作区? ...或者代表其他人创建工作区的其他方式?
答案 0 :(得分:7)
您可以使用tf workspace命令使用命令脚本创建工作区。然后,您可以使用tf workfold命令映射工作文件夹。 workspace命令具有/ template选项
例如:
为某人创建工作区
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 :(得分:2)
根据您对整个过程的细粒度控制程度,我发现此PowerShell脚本有效:
"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文章中列出了所有可以定义的参数:http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.createworkspaceparameters.aspx此方法优于tf.exe的一个优点是您可以显式定义工作区位置(即服务器或本地),并且您对创建时定义的映射有更多的控制权。
您应该只需调整相应的设置并将此代码转储到任何* .ps1文件中。
答案 2 :(得分:0)
您还可以将工作区映射从一个工作区复制并粘贴到另一个工作区。
您还可以将映射粘贴到记事本中,更新它们,然后将它们复制并粘贴回工作区编辑器。
您在记事本中看到的格式:
<serverpath>: <localPath>
示例:
$/TeamProj1/Trunk/: C:\TFS\WorkingFolder\
答案 3 :(得分: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