How can I remove/fix a ghost workspace

前端 未结 3 1396
孤街浪徒
孤街浪徒 2021-02-14 03:19

Somehow I have ended up with a \"ghost\" workspace. It doesn\'t show up in Visual Studio under Manage Workspaces. When I connect to VS Team Services and open source control expl

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-14 04:09

    Buck is most certainly right about the identity issue. I stumbled upon it yesterday after an Azure AD migration. Fortunately there is a way around. Here is the PowerShell solution that I found with the help of the Team Foundation .NET assemblies. (For the record I am using PowerShell version 5.0.)

    1. Load these assemblies into your PowerShell session (where the version matches your installation of Visual Studio; in my case Version=12.0.0.0 corresponds to VS 2013):
    Add-Type -AssemblyName 'Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    Add-Type -AssemblyName 'Microsoft.TeamFoundation.VersionControl.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    1. Connect to the VSTS version control server:
    $uri = 'https://me.visualstudio.com/defaultcollection'
    $tfs = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($uri)
    $vcs = $tfs.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
    1. Query for the workspace you want to delete and retrieve its qualified name:
    $vcs.QueryWorkspaces('WorkspaceName', $null, $null) | % QualifiedName

    You might have a look at the QueryWorkspaces online help. If the call to QueryWorkspaces() does not return anything, which is the case if you only pass a computer name, you might have to issue it this way instead:

    Invoke-Method -InputObject $vcs -MethodName 'QueryWorkspaces' -Arguments $null, $null, 'ComputerName' | % QualifiedName

    It seems to be dued to the fact that $null cannot be passed directly from within PowerShell. I had the issue before and this post helped me (but it seems to be now retired).

    1. Pass the qualified name to TF.exe to delete the workspace (remember it is PowerShell, hence the --%):
    tf workspace /collection:$uri --% /delete 'WorkspaceName;11111111-2222-3333-4444-555555555555'

    Notice that you might as well call the Delete() method on the Workspace object returned by the QueryWorkspaces() issued against VCS...

    HTH

提交回复
热议问题