-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTFS.fsx
More file actions
49 lines (35 loc) · 1.55 KB
/
TFS.fsx
File metadata and controls
49 lines (35 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
namespace TFS
#r "Microsoft.TeamFoundation.Client"
#r "Microsoft.TeamFoundation.VersionControl.Common"
#r "Microsoft.TeamFoundation.VersionControl.Client"
open Microsoft.TeamFoundation.Client
open Microsoft.TeamFoundation.VersionControl.Client
exception WorkspaceNotFound of string
type TFSConnection(workspaceDirectory) =
let workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(workspaceDirectory)
let tfsConnection =
if workspaceInfo = null then
raise (WorkspaceNotFound workspaceDirectory)
new TfsTeamProjectCollection(workspaceInfo.ServerUri)
let mutable versionControlServerOption = None
let mutable workspaceOption = None
new() = new TFSConnection(".")
member this.VersionControlServer
with get() =
match versionControlServerOption with
| Some(value) -> value
| None ->
let instance = tfsConnection.GetService<VersionControlServer>();
versionControlServerOption <- Some(instance)
instance
member this.Workspace
with get() =
match workspaceOption with
| Some(value) -> value
| None ->
let instance = this.VersionControlServer.GetWorkspace(workspaceInfo)
workspaceOption <- Some(instance)
instance
interface System.IDisposable with
member this.Dispose() =
tfsConnection.Dispose()