Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net Team Foundation服务器,在没有工作区的情况下签出文件_Vb.net_Tfs - Fatal编程技术网

Vb.net Team Foundation服务器,在没有工作区的情况下签出文件

Vb.net Team Foundation服务器,在没有工作区的情况下签出文件,vb.net,tfs,Vb.net,Tfs,我有TFS url,有源文件位置,但没有工作区路径。 如何在没有工作区的情况下签出文件,或者如何查找某个文件的工作区 我已经在TFS中为签出文件制定了解决方案,但在某些情况下,我并没有工作区路径或名称 Dim TeamFoundationServerURL As String ="TFS url" Dim TeamProjectCollection As TfsTeamProjectCollection 'Get project collectio TeamProjectCollection

我有TFS url,有源文件位置,但没有工作区路径。 如何在没有工作区的情况下签出文件,或者如何查找某个文件的工作区

我已经在TFS中为签出文件制定了解决方案,但在某些情况下,我并没有工作区路径或名称

Dim TeamFoundationServerURL As String ="TFS url"

Dim TeamProjectCollection As TfsTeamProjectCollection

'Get project collectio
TeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection( _
            New Uri(TeamFoundationServerURL), New UICredentialsProvider())

TeamProjectCollection.EnsureAuthenticated()

Dim Workspace As Workspace

' get Version Control
Dim VersionControlServer As VersionControlServer
VersionControlServer = TeamProjectCollection.GetService(Of VersionControlServer)()

'location to check out files to:
Dim WorkspacePath As String = "__I dot have this path ___"

'find workspace
Workspace = VersionControlServer.GetWorkspace(WorkspacePath)

'Check out file
Workspace.PendEdit(SorceFilePath)

谢谢

在没有工作区的情况下签出是不可能的。因此,如果您需要签出并且没有任何工作区信息,您应该根据需要创建一个wokspace。
还有一个选项可以在不使用工作区VersionControlServer.DownloadFile的情况下下载文件。有关详细信息,请参阅。但它不会被签出(如“查看”控制台命令)

无法在没有工作区的情况下签出。因此,如果您需要签出并且没有任何工作区信息,您应该根据需要创建一个wokspace。
还有一个选项可以在不使用工作区VersionControlServer.DownloadFile的情况下下载文件。有关详细信息,请参阅。但它不会被签出(如“查看”控制台命令)

我想用我的autobuild做这个。我让它签出一个版本文件,然后再签回(更新后)。因为这是构建机器,所以我没有可以保证的工作空间映射

最后我只是检查我需要的文件是否已映射。如果不是的话,我会把它画出来

我知道这不是你要找的解决办法,但我想我会把它扔掉,让你考虑。 以下是我执行签出和签入操作的代码:

private Version GetVersionFromTFS(Workspace currentWorkspace, string versionFileLocation, string versionFileName, out string localVersionPath)
{
    // Make sure we have a map to the version file
    if (!currentWorkspace.IsServerPathMapped(versionFileLocation))
    {
        // Map the version file to somewhere.
        currentWorkspace.Map(versionFileLocation, @"C:\temp\BuildVersions" + Guid.NewGuid());
    }

    // Make sure we have the latest from source control.
    GetRequest getRequest = new GetRequest(new ItemSpec(versionFileLocation + versionFileName,RecursionType.None), VersionSpec.Latest);
    currentWorkspace.Get(getRequest, GetOptions.Overwrite);           

    localVersionPath = currentWorkspace.GetLocalItemForServerItem(versionFileLocation + versionFileName);

    string oldVersion = "1.0.0.0";
    if (File.Exists(localVersionPath))              
        oldVersion = File.ReadAllText(localVersionPath);

    return new Version(oldVersion);
}

private void UpdateVersionBackToTFS(Workspace currentWorkspace, string versionFileLocation, string versionFileName, Version newVersion, String localVersionPath)
{
    File.WriteAllText(localVersionPath, newVersion.ToString()); 

    WorkspaceCheckInParameters parameters = new WorkspaceCheckInParameters(new[] {new ItemSpec(versionFileLocation + versionFileName, RecursionType.None)}, "***NO_CI*** - Updating Version" );

    currentWorkspace.CheckIn(parameters);

}

我想用我的autobuild做这个。我让它签出一个版本文件,然后再签回(更新后)。因为这是构建机器,所以我没有可以保证的工作空间映射

最后我只是检查我需要的文件是否已映射。如果不是的话,我会把它画出来

我知道这不是你要找的解决办法,但我想我会把它扔掉,让你考虑。 以下是我执行签出和签入操作的代码:

private Version GetVersionFromTFS(Workspace currentWorkspace, string versionFileLocation, string versionFileName, out string localVersionPath)
{
    // Make sure we have a map to the version file
    if (!currentWorkspace.IsServerPathMapped(versionFileLocation))
    {
        // Map the version file to somewhere.
        currentWorkspace.Map(versionFileLocation, @"C:\temp\BuildVersions" + Guid.NewGuid());
    }

    // Make sure we have the latest from source control.
    GetRequest getRequest = new GetRequest(new ItemSpec(versionFileLocation + versionFileName,RecursionType.None), VersionSpec.Latest);
    currentWorkspace.Get(getRequest, GetOptions.Overwrite);           

    localVersionPath = currentWorkspace.GetLocalItemForServerItem(versionFileLocation + versionFileName);

    string oldVersion = "1.0.0.0";
    if (File.Exists(localVersionPath))              
        oldVersion = File.ReadAllText(localVersionPath);

    return new Version(oldVersion);
}

private void UpdateVersionBackToTFS(Workspace currentWorkspace, string versionFileLocation, string versionFileName, Version newVersion, String localVersionPath)
{
    File.WriteAllText(localVersionPath, newVersion.ToString()); 

    WorkspaceCheckInParameters parameters = new WorkspaceCheckInParameters(new[] {new ItemSpec(versionFileLocation + versionFileName, RecursionType.None)}, "***NO_CI*** - Updating Version" );

    currentWorkspace.CheckIn(parameters);

}