我正在尝试为可能没有管理员权限的用户自动将tfs集合映射到本地工作空间。
当前,我正在尝试使用
$ tfs = [Microsoft.TeamFoundation.Client.TeamFoundationFactory] :: GetServer($ tfsServer)
获取TFS服务器。但是,此行代码会导致错误提示
找不到类型[Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]
我包括以下行:
脚本中的添加类型-路径“ $ path.Microsoft.TeamFoundation.Client.dll”
前面。
我早些时候发布了this question,但我仍在针对该问题将相关的DLL放入GAC。我不再这样做了,因为操作GAC通常需要管理员权限,并且我不能保证脚本用户具有这些权限。
现在,我决定不将DLL添加到GAC中,正在运行的代码现在失败。
有没有一种方法可以在不使用GAC或其他任何需要管理员权限的情况下获取TFS服务器,如果可以,该怎么办?
答案 0 :(得分:0)
像这样修改代码:
$TfsAssembliesPath="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer"
Add-Type -Path "$TfsAssembliesPath\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.ServiceBus.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.VisualStudio.Services.Common.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.VisualStudio.Services.WebApi.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.VisualStudio.Services.Client.Interactive.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.Core.WebApi.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.Common.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.Client.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.TestManagement.Common.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.ProjectManagement.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.Build.Client.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.Build.Common.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.Git.Client.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.SourceControl.WebApi.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.WorkItemTracking.Client.QueryLanguage.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.WorkItemTracking.Common.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.WorkItemTracking.Proxy.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.WorkItemTracking.Client.dll"
Add-Type -Path "$TfsAssembliesPath\Microsoft.TeamFoundation.TestManagement.Client.dll"
[string]$tfsCollectionUrl="TFS collection URL"
[string]$tfsTeamProjectName="team project"
$teamProjectCollection=[Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsCollectionUrl)
$ws = $teamProjectCollection.GetService([type]"Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore")
$proj = $ws.Projects[$tfsTeamProjectName]
$wit = $proj.WorkItemTypes["Task"]
#Create a new work item of that type
$workitem = $wit.NewWorkItem()
$workItem.Title = "Sample Task Title 3"
$workItem.Description = "Sample Description"
$workitem.AreaPath = $tfsTeamProjectName
$workitem.IterationPath = $tfsTeamProjectName
$workItem.Save()