How to remove a TFS Workspace Mapping?

2019-01-08 05:30发布

I had a project in tfs within a team project then we moved the project to a different location in another team project.

I had configured Jenkins to connect to the team project and build my solution but when I changed the settings to connect to the new tfs team project, it gives me the below error:

[workspace] $ "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe" workspace -new Hudson-ProjectName1-Build-MASTER;domain1\username1 -noprompt -server:http://domain.net:8080/tfs/newteamproject ********
The path D:\jenkins\jobs\ProjectName1-Build\workspace is already mapped in workspace Hudson-ProjectName1-Build-MASTER [http://domain.net:8080/tfs/oldteamproject].

So the above shows that there is an existing workspace so I ran the below command to remove it

tf workspace -delete Hudson-ProjectName1-Build-MASTER;domain1\username1 -noprompt -server:http://domain.net:8080/tfs/oldteamproject

and it prompted that the workspace has been removed but I'm still getting the same error.

I also checked whether the mapping has been removed or not by running the below command:

tf workspace -server:http://domain.net:8080/tfs/oldteamproject Hudson-ProjectName1-Build-MASTER

but it says the workspace doesn't exist as expected.

So, I thought it might be caching it somewhere and ran the below command:

tf workspaces /remove:* /collection:http://domain.net:8080/tfs/oldteamproject

and it said "No workspace in the cache matches * from server http://domain.net:8080/tfs/oldteamproject"

so I'd guess it's not even cached.

So what's causing the error and how to resolve it?

18条回答
爷、活的狠高调
2楼-- · 2019-01-08 05:44

If the mentioned clues are not helping you then download Team Foundation Sidekick and using that you can delete the workspaces.

查看更多
3楼-- · 2019-01-08 05:45

I’m using TFS 2012. I tried everything that was suggested online: deleted cache folder, used the workspaces dropdown, tf workspaces /remove:*, cleared credentials from Control Panel, IE, etc.

Nothing worked, I believe my workspace got corrupted somehow. Finally, I went to the TFS database and ran the following queries. That worked! Of course be very careful when messing with the database, take backups, etc.

The database is called Tfs_<<your_TFS_collection_name>>. Ignore the Tfs_Configuration MSSQL database. I'm not sure but if you don't have a Tfs_<<your_TFS_collection_name>> database, settings might be in the Tfs_DefaultCollection database. Mapping is stored in tbl_WorkingFolder.LocalItem.

/*Find correct workspace*/
SELECT WorkspaceId, * FROM tbl_Workspace ORDER BY WorkspaceName

/*View the existing mapping*/
SELECT LocalItem, * FROM tbl_WorkingFolder WHERE WorkspaceId = <<WorkspaceId from above>>

/*Update mapping*/
UPDATE tbl_WorkingFolder
SET LocalItem = 'D:\Legacy' WHERE WorkspaceId = <<WorkspaceId from above>>
/*LocalItem = NULL might work too but I haven't tried it*/
查看更多
来,给爷笑一个
4楼-- · 2019-01-08 05:45

Run tf workspaces to view current workspace mappings. Output looks like:

enter image description here

Then run tf workspace /delete "{workspace};{user}

Using output above, to delete workspace bi:

tf workspace /delete bi;James Wierzba

查看更多
贪生不怕死
5楼-- · 2019-01-08 05:47

From VS:

  1. Open Team Explorer
  2. Click Source Control Explorer
  3. In the nav bar of the tool window there is a drop down labeled "Workspaces".
  4. Extend it and click on the "Workspaces..." option (yeah, a bit un-intuitive)
  5. The "Manage Workspaces" window comes up. Click edit and you can add / remove / edit your workspace

source control explorer

From VS on a different machine

You don't need VS to be on the same machine as the enlistment as you can edit remote enlistments! In the dialog that comes up when you press the "Workspaces..." item there is a check box stating "Show Remote Workspaces" - just tick that and you'll get a list of all your enlistments:

show remote workspaces

From the command line

Call "tf workspace" from a developer command prompt. It will bring up the "Manage Workspaces" directly!

查看更多
地球回转人心会变
6楼-- · 2019-01-08 05:50

I managed to remove the mapping using the /newowner command as suggested here:

How can I regain access to my Team Foundation Server Workspace?

The command opened an Edit Workspace windows where I removed the mapping. Afterwards I deleted the workspace I didn't need.

查看更多
时光不老,我们不散
7楼-- · 2019-01-08 05:53

None of the answers here removed my workspaces. But here is one solution that may work for you.

  1. Open up a Visual Studio command prompt
  2. Close Visual Studio first or the delete command may not delete the workspace
  3. List the workspace commands -> tf /? to find the commands available to you from the version of TFS.
  4. List the workspaces -> tf workspaces
  5. Delete the workspace -> tf workspace YourWorkspace /delete
查看更多
登录 后发表回答