如何在共享查询TFS中创建自定义文件夹?

时间:2016-02-12 18:05:08

标签: powershell tfs tfs2015

我试图在"共享查询"内部创建一个文件夹。 TFS工作项文件夹通过POSH。

key=operator.itemgetter(1)),

$ teamProject返回为null。我可以枚举所有其他项目,但不能枚举我指定为参数的项目。 有什么线索?

1 个答案:

答案 0 :(得分:1)

您需要检查您指定的项目名称是否存在于团队项目集合中,并确保您具有访问它的权限。

在"共享查询"下创建文件夹文件夹,有关详细信息,请参阅以下代码:

$pathToAss4 = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v4.5"
Add-Type -Path "$pathToAss2\Microsoft.TeamFoundation.WorkItemTracking.Client.dll"
Add-Type -Path "$pathToAss2\Microsoft.TeamFoundation.VersionControl.Client.dll"
Add-Type -Path "$pathToAss4\Microsoft.TeamFoundation.ProjectManagement.dll";

$projectname = "ProjectName"
$CollectionUrl = "http://xxx.xxx.xxx.xxx:8080/tfs/defaultcollection"
$tfs = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($CollectionUrl)
$ws = $tfs.GetService([Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore])
$teamProject = $ws.Projects["$projectname"]
$addfoldername = "NewFolder"
$addfolder = new-object Microsoft.TeamFoundation.WorkItemTracking.Client.QueryFolder -ArgumentList "$addfoldername"
$queryhi = $teamProject.QueryHierarchy
$parentfolder = $queryhi["Shared Queries"]
$parentfolder.Add($addfolder)
$teamProject.QueryHierarchy.Save()