我在PowerShell中构建一个函数,它创建一个新的Workspace并获取除了一些其他TFS和文件系统相关任务之外指定的最新版本的目录。现在我使用PowerTools和TFS组件的混合来完成工作。看来除了创建一个新的工作区,我可以使用Power Tools完成所有工作。在没有明确加载Team Foundation程序集的情况下,我还没想出如何做到这一点。是否有可能,如果是这样的话?
这就是我现在正在做的事情
#Install required TFS assemblies
"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" }
#Install TFS PowerTools snappin for basic tasks
If ( (Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
}
## Set applicable parameters
#Get the TFS server object
$tfs=Get-TfsServer -Name $tfsName
#Get the version control service object
#This is what I want to do with PowerTools - like a new-item or something
$vcs = $tfs.GetService([type]"Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer")
#Create a Workspace parameters object
$workspaceParameters = New-Object Microsoft.TeamFoundation.VersionControl.Client.CreateWorkspaceParameters -ArgumentList $wsName
#Create the Workspace
$tfsw = $vcs.CreateWorkspace($workspaceParameters)
# Add any working folders that you would defined below
$tfsw.Map($tfsLocation, $localFolder)
答案 0 :(得分:1)
TFPT管理单元中的唯一new
命令是New-TfsChangeset
和New-TfsShelveset
。您有理由不能使用tf.exe workspace /new ...
和tf.exe workfold ...
吗?