Team Foundation:没有工作文件夹映射

时间:2016-06-24 11:50:35

标签: .net vb.net tfs2013

Dim _versionControlServer As VersionControlServer = tfs.GetService(Of VersionControlServer)()
Dim _workspace As Workspace = _versionControlServer.GetWorkspace(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())))
  

GetWorkspace()抛出异常:“没有工作文件夹映射...”

(Windows 10,Visual Studio 2012,VB.Net,TeamFoundation服务器版本12.0,特定版本= true)

2 个答案:

答案 0 :(得分:0)

检查this case

使用VersionControlServer.CreateWorkSpace方法创建工作区并设置工作文件夹(使用其中一个接受WorkingFolder()的重载。)

答案 1 :(得分:0)

此代码适用于VS2013和VS2015。

Imports Microsoft.TeamFoundation.Client
Imports Microsoft.TeamFoundation.VersionControl.Client

Module Module1

    Dim localFolder As String = "C:\TFS\Path\to\source"
    Dim serverFolder As String = "$/Path/to/source"
    Dim tfsUri As Uri = New Uri("https://tfs.yourcompany.com/tfs/YourCollection")
    Dim workspaceName As String = "newWorkspace"

    Function CreateOrMapWorkspace() As Workspace
        REM TfsTeamProjectCollection Is IDisposable so a "using" Is recommended.
        Using ttpc As New TfsTeamProjectCollection(tfsUri)


            Dim vcs As VersionControlServer = ttpc.GetService(Of VersionControlServer)()
            Dim ws As Workspace
            Try

                ws = vcs.GetWorkspace(localFolder)
            Catch

                REM create workspace
                Dim cwp As CreateWorkspaceParameters = New CreateWorkspaceParameters(workspaceName)
                cwp.Folders = Array.CreateInstance(GetType(WorkingFolder), 1)
                cwp.Folders(0) = New WorkingFolder(serverFolder, localFolder)
                ws = vcs.CreateWorkspace(cwp)
            End Try

            Return ws

        End Using
    End Function

    Sub Main()
        CreateOrMapWorkspace()
    End Sub

End Module