您需要Visual Studio 2005 SDK来获取所需的程序集。SDK还包括一些C中的示例,您可以将其用作参考,以及一些Dokumentation。两者都不是很好(imho),所以你可能需要做一些谷歌搜索。
我编写了以下代码作为概念验证,但它可能会帮助您开始。注意,这是在VS2010中编写的,因此您可能需要使用i语句来引用正确的程序集。
#light
// #I @"C:\Program Files (x86)\Microsoft Visual Studio 2008 SDK\VisualStudioIntegration\Common\Assemblies\"
#r "Microsoft.TeamFoundation"
#r "Microsoft.TeamFoundation.Client"
#r "Microsoft.TeamFoundation.WorkItemTracking.Client"
#r "Microsoft.TeamFoundation.VersionControl.Client"
open System
open System.Collections.Generic
open System.Net
open Microsoft.TeamFoundation
open Microsoft.TeamFoundation.Client
open Microsoft.TeamFoundation.WorkItemTracking.Client
open Microsoft.TeamFoundation.VersionControl.Client
type TeamFoundationClient(uri, credentials : ICredentials) =
let server = new TfsTeamProjectCollection (Uri uri, credentials)
let workitemStore = server.GetService(typeof<WorkItemStore>) :?> WorkItemStore
let versionControlServer = server.GetService(typeof<VersionControlServer>) :?> VersionControlServer
member this.ExecuteQuery wiql =
workitemStore.Query(wiql)
|> Seq.cast<WorkItem>
member this.GetWorkItem id =
workitemStore.GetWorkItem (id : int)
member this.GetChangeset changesetUri =
versionControlServer.ArtifactProvider.GetChangeset (Uri changesetUri)
member this.GetChangesets (wi : WorkItem) =
let isChangeset (link : Link) =
match link with
| :? ExternalLink as link' when link'.LinkedArtifactUri.Contains("Changeset") -> Some (link')
| _ -> None
wi.Links
|> Seq.cast<Link>
|> Seq.choose isChangeset
|> Seq.map (fun l -> l.LinkedArtifactUri)
static member CreateCredentials (username : string) (password : string) (domain : string) =
(NetworkCredential (username, password, domain)) :> ICredentials
/HuSOM