147

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-eg.net:8080/tfs/newteamproject ********
The path D:\jenkins\jobs\ProjectName1-Build\workspace is already mapped in workspace Hudson-ProjectName1-Build-MASTER [http://domain-eg.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-eg.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-eg.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-eg.net:8080/tfs/oldteamproject

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

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

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

The Light
  • 26,341
  • 62
  • 176
  • 258
  • 3
    TFS Workspaces must contain unique working folder mappings *per machine*, not just per user and machine. Is it possible that you set up a TFS workspace that contains `D:\jenkins\jobs\ProjectName1-Build\workspace` as another TFS user while testing? – Edward Thomson Apr 03 '13 at 13:14
  • 9
    Try this from the build machine - C:\Users\{UserName}\AppData\Local\Microsoft\Team Foundation\3.0\Cache and delete all that's in the folder – SoftwareCarpenter Apr 03 '13 at 16:32
  • Ran into the same problem, my case was a white space at the beginning of the workspace name – Daniel Rapaport Jan 30 '14 at 07:23
  • I recently remapped my TFS root and had the same issue. Turns out in my case, TFS explorer was just showing the old (last) path I has checked out to in the "Local Path:" and it was grayed out and not clickable (blue). I Did a get latest and it put everything in the correct new mapping and then the path became blue / active. If you deleted all the old mappings, it may just be showing the last local folder you did a get latest to, which is not where it will put files now under the new mapping. – Rich M Feb 12 '20 at 20:41

21 Answers21

210

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!

Bogdan Gavril MSFT
  • 20,615
  • 10
  • 53
  • 74
  • 2
    He's doing this on a build machine, and likely doesn't have visual studio installed there. – Erik Funkenbusch Jun 30 '14 at 05:15
  • 7
    Thanks this works, yet another reason TFS is aweful. – schmoopy Jan 30 '16 at 23:10
  • 6
    I removed all workspaces. then added new, again getting error that my folder is already mapped to a wrokspace (of old/removed) url tfs. Unable to map to new tfs/workspace. M using vs 2015 – Sami Mar 11 '16 at 15:19
  • 1
    Why does this even need to be a confusing showstopper? – ajeh Apr 22 '16 at 17:20
  • 11
    Doesn't work. Workspace remains no matter what. reboot, restart vs, pray, click heels together 3x... nothing... won't leave. Can't map to new... can't work. – Beau D'Amore Sep 28 '16 at 18:39
  • 3
    This is the highest rated answer, yet it doesn't address the scenario where the workspace will NOT delete (as Beau mentioned above). You remove it, close the dialog, open again, and it's back. Absolutely maddening. – dapug Mar 04 '17 at 20:53
  • @dapug - I am sorry I cannot help troubleshoot what seems to be a TFS bug. AFAIK, support for VSTS (which includes TFS) is free - try to log a ticket https://www.visualstudio.com/team-services/tfs_support/ – Bogdan Gavril MSFT Mar 07 '17 at 12:47
  • For those that say it stays mapped: when you change the workspace, TFS will ask to do an automatic get latest. Click 'Yes', otherwise it will not actually commit the new mappings. That did it for me. – Didii Jun 18 '19 at 09:06
126

I ran into the same problem, and was able to fix it by manually deleting all the files in the TFS cache, located here:

%LocalAppData%\Microsoft\Team Foundation\3.0\Cache

or 4.0, 5.0, etc.

Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
brainiac10
  • 1,733
  • 1
  • 12
  • 8
  • 4
    Thanks, this works for me because my local tfs cached data was out of sync when my company changed the network domain name. – dsum Jan 17 '14 at 00:22
  • 6
    Not for me. It is still telling me `the path is already mapped in workspace {mypcname};domain\zhasan` – SearchForKnowledge Aug 22 '14 at 13:48
  • 5
    I had a \4.0\Cache and \5.0\Cache that I got rid of. In case that helps anyone. – fooser Sep 02 '14 at 15:51
  • 2
    This worked for me also. Pro Tip, before deleting the files in the `Cache` folder, take a minute to copy all the files and folders and keep it in a backup folder, just in case it doesn't work for you and you have to restore your TFS to it's previous state. – Shiva Sep 06 '14 at 01:25
  • Actually you can delete everything under `Team Foundation` if you want perform a clean re-synch. – Supersharp Jan 15 '16 at 16:12
  • For `SYSTEM` user you should check these paths: `C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Team Foundation` or `C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Team Foundation` – Yusuf Tarık Günaydın Apr 13 '16 at 10:05
  • Reviewing file:///C:/Users/xxxxxxxx/AppData/Local/Microsoft/Team%20Foundation/5.0/Cache/LocationServerMap.xml may help you target with Cache folders to delete. – Alan Larimer Aug 02 '16 at 12:57
  • I was facing the issue of not downloading the files from TFS. It used to stuck after some files got downloaded. Removing TFS cache files solved my problem. Thanks. – PSR Apr 07 '17 at 08:45
  • Yes its works, thank you. @Beau you need to close visual studio and then clean cache folder item – Satish Singh Apr 13 '17 at 10:13
  • did the trick, this works only if the workspace no longer exists... if it exists then you have to use the one flagged as answered – Egli Becerra Nov 08 '17 at 22:45
22

Follow these steps to remove mapping from TFS:

  1. Open team explorer
  2. Click Source Control
  3. Right click on you project
  4. Click on Remove Mapping
Ken Clark
  • 2,500
  • 15
  • 15
  • 6
    No option for remove mapping.. still facing the error that your folder is already mapped to some workspace of an old/removed tfs url.. M using vs 2015 – Sami Mar 11 '16 at 15:22
  • 1
    Doesn't exist in Visual Studio Premium 2013 – damd Mar 29 '16 at 07:34
  • 1
    I think this option is only available when targeting the originally mapped folder. So if I map an entire team project with recursion, I can only *unmap* the entire team project, whereas if I just map the solution folder I can then unmap that happily enough. – Jeff Dec 16 '16 at 01:50
  • @Sami After right click on your project, `Remove Mapping` will show you under `Advanced` section – Uday Nov 28 '18 at 15:12
12

The error is genuine. You might have created workspace with same name on different machine. Now you may have changed machine having different machine name.

So here is work-around that will definitely work.Following is work-around.

  1. Go to "Team-Explorer"
  2. Go to "Source-Control"
  3. Go to Workspace drop-down
  4. Click on "Workspaces..."
  5. A pop-up window will appear
  6. Click on "Show remote workspaces"
  7. Now delete the workspace which is conflicting and you can proceed your work.
smthakur19
  • 195
  • 1
  • 9
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – alextansc Aug 12 '15 at 07:15
  • the link will now be working fine. Thank you alextansc – smthakur19 Aug 12 '15 at 07:22
  • @smthakur19 what alex tried to say is, if one day that link is no longer available (website down, page deleted, etc.) this answer will be useless. So it would be nice to include the essential text&code from the referenced link and include it in the answer all. So, the source of the answer and the question will both be SO. – Beytan Kurt Aug 12 '15 at 12:46
  • elaborated explaination, however I could not add images as my reputation is below 10. – smthakur19 Aug 12 '15 at 13:42
  • 1
    broken link, procedure does NOT work. Workspace remains – Beau D'Amore Sep 28 '16 at 18:47
  • link is removed – smthakur19 Jul 13 '17 at 09:58
7

Please follow the below steps:

Ctrl + Run 

Copy and Past

%LocalAppData%\Microsoft\Team Foundation

You will get different version of TFS e.g enter image description here

Click on each folder and you will get

enter image description here

Now Delete all data in these folder.

Reopen the Visual studio.

Thanks.

Satish Singh
  • 2,169
  • 3
  • 23
  • 32
5

All of the answers here seem to be partial answers that don't work in all cases. I think this answer will work in all cases, assuming you have proper permissions.

  1. Open up the Developer Command Prompt. In my case, I've tested this with the Developer Command Prompt for VS 2019.
  2. Type this command: tf workspaces

Note that the results can list a couple tables with identical structure. If you only see one table, then some of the assumptions in the other answers can work for you. However, if you see two or more tables, then that Collection string is important! For our examples, we're going to assume you have two Collections (two is no different than four other than one is more tedious than the other to go through it):

https://dev.azure.com/foo and https://bar.visualstudio.com/

With luck, you will know which one of these two you want to work with. However, if you need to cycle through them all, then you'll just have to do that one collection at a time. Each "Collection" here is the same as an "Organization" in Azure DevOps (I think).

If you don't use this Collection detail, then you might see an error message:

Unable to determine the source control server.

  1. Next, type this command for the collection you want to use:

tf workspaces /computer:* /owner:* /collection:https://dev.azure.com/foo

This will give you a much more complete picture of what you're dealing with. This gets especially nasty if you have had multiple MSAs and Org accounts hitting this repo from the same computer. In fact, you might have multiple seemingly-identical entries. If you try to delete them based on what you currently know, it may not work. But we can get more information.

  1. Next, we're going to run the same command but append /format:xml to the end of it:

tf workspaces /computer:* /owner:* /collection:https://dev.azure.com/foo /format:xml

This now gives you a bunch of XML with some additional properties. The ones that we likely care about the most are the Owner Aliases. This is the missing information you need to now go through and delete these workspaces. Without this additional information, it's easy to hit a wall and be stuck with an error message:

Specify one workspace.

  1. Now we have all of the info we need. Given the additional OwernAliases entries, select the unique entry (or repeat if more than one) that you wish to delete and use this following command (a couple examples are listed):

    • tf workspace /delete /collection:https://dev.azure.com/foo "MyWorkspaceName;Windows Live ID\John.Doe@hotmail.com"
    • tf workspace /delete /collection:https://dev.azure.com/foo "MyWorkspaceName;John Doe"
    • tf workspace /delete /collection https://dev.azure.com/foo "MyWorkspaceName;2C3E8474-A39C-4785-8794-DC72F09981E6\John.Doe@Example.com"

The GUID identifies an AAD directory and the quotes are there to handle any spaces that might be in an alias. The "MyWorkspaceName" comes from your previous queries listing out the workspaces.


Without this very thorough approach, it's possible that all of the other answers in this question will fail for you. While some of those efforts will clear out local workspaces, they will not clear out server workspaces, which you can still conflict with. Additionally, if you have previously used a different account things can get hairy, like if you switched from an MSA to an AAD account. And things get REALLY hairy if you have an MSA account and multiple AAD accounts all with the same email address that you have used from the same workstation. And then it gets super crazy hairy if multiple of those all used the default name for the workspace: your computer's hostname. In my case, I had four workspaces all with the same Workspace name, Owner name, and Computer name (i.e. the first query without the XML formatting had 4 identical records!).


I do not know if there's a more graphcial way to manage these than this. I have looked and not yet found a better way than this.

Jaxidian
  • 13,081
  • 8
  • 83
  • 125
4

Update 2019-01-23

If you’re repeatedly getting the following error The workspace wkspaceEg does not exist… even after employing the correct username (wkspcOwnerDomain\wkspcOwnerUsername) in the tf workspace command, e.g.,

tf workspace "wkspaceEg;wkspcOwnerDomain\wkspcOwnerUsername" /collection:http://tfs.example.com:8080/tfs/collectionEg /login:TFSUsername,TFSPassword

then the tf workfold command may help fix it. See this question.

If even that doesn’t work and you’re unable/unwilling to use TFS Sidekicks, proceed to the risky last-ditch option below.


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.00\TFS\Source\Workspaces\teamProjEg' WHERE
/*LocalItem = NULL might work too but I haven't tried it*/
WorkspaceId = <<WorkspaceId from above>>
4

Team Explorer > Source Control Explorer >

TFS Remove MAPPING

Deepu Reghunath
  • 8,132
  • 2
  • 38
  • 47
  • The answer from Ahmed elshiekh is working for me: File -> Source Control -> Advanced -> Workspaces -> Choose the workspace in Manage Workspaces and click "Edit" Then you can change the local folder. – AH. May 31 '21 at 08:56
3

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.

Community
  • 1
  • 1
Alex Kamburov
  • 405
  • 4
  • 10
2

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
  • This is the way to go if you have two workspaces with the same name but for different users (e.g. your normal account and an administrator account). Those two workspaces will not show up as two spaces if you open the "Workspaces" view as outlined in the other answers - only the one for the current user will be listed. In my case, it then was the second workspace (for the admin account) which was blocking the operations. If you do as described in this answer, step 5 will allow you to delete the second workspace using "tf workspace YourWorkspace;HiddenUser /delete". – H. Breitkreutz Jul 09 '18 at 18:00
2

You don't have to delete the entire Cache folder. you lose all settings / preferences The workspace mappings are stored in a file called:

VersionControl.config under the users local settings/application data directory. located here in windows 7:

%LocalAppData%\Microsoft\Team Foundation\x.0\Cache\Volatile

where x= 3.0,4.0, 5.0,6.0 etc.

Inside this you will find guid named folders , open each of them, manually editing the forementioned file, to remove the workspace mapping(directory path will be present in mappedpaths attribute) from that local folder to the TFS server (which is no longer in usage).

Sundara Prabu
  • 2,361
  • 1
  • 21
  • 20
2

File -> Source Control -> Advanced -> Workspaces -> Choose the workspace in Manage Workspaces and click "Edit" Then you can change the local folder.

Ahmed elshiekh
  • 141
  • 1
  • 2
1

Finally deleted ALL workspaces and started from scratch. Fixed.

smirkingman
  • 6,167
  • 4
  • 34
  • 47
1

I was prompted to login to our TFS server via Visual Studio, so I used my SU account which is typically required for server access. This led to some issues, and I ended up mapping to a different folder, not realizing I had just duplicated all my stuff. At some point, Visual Studio reverted back to my regular user, I "lost" pending changes, and noticed that new pending changes were placed by in my old mapping.

When I would try to remap to the new location (that the SU account was linked to) in an attempt to recover my pending changes, it would tell me it was already mapped to the SU, and I couldn't do that, but had no way of removing the map! Show remote workspaces, removing all workspaces via command line, etc revealed nothing. I then thought "what if it's actually linked to the SU user account on my computer, not the domain." I logged in as my SU locally, and sure enough, there was a workspace all setup for that user. I removed the mapping, and was able to go back to my regular user and remap without issue.

Moral of the story, perhaps another user is logged in on the same machine, which isn't visible from the currently logged in user, thus you cannot remove or even see the mappings.

1

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

Mr. N. Das
  • 61
  • 8
1

Following are the steps to remove mapping of a project from TFS:

(1) Click on View Button.

(2) Open Team Explorer

(3) Click on Source Control

(4) Right click on your project/Directory

(5) Click on Remove Mapping

(6) Finally Delete the Project form local directory.

0

You can also remove a tfs mapping by simply editing your .sln file and removing the GlobalSection element for the tfs binding.

CalCof
  • 46
  • 2
0

Thanks for your help!

Find problem workspace SELECT * FROM tbl_Workspace WHERE WorkspaceName like '%xxxxx%'

Find desired workspace SELECT * FROM tbl_Workspace WHERE WorkspaceName like '%zzzzz%'

Select Edit Top 200 tbl_WorkingFolder then Find the problem mapping SELECT * FROM tbl_WorkingFolder WHERE WorkspaceId = Problem WorkspaceId from above

Change the WorkspaceId to the desired WorkspaceId

Finally goto Project Explorer and select Remove Mapping on the project

Modify VB6 MSSCCPRJ.SCC to match the desired WorkSpace

vmaynard
  • 1
  • 1
0

First download and install Team Explorer plugin in your system and then go to the Source Control Explorer. In the navigation pane find the Workspace field and click on Workspaces option. After clicking on Workspaces option, you will see all the workspaces that are mapped. Click on the remove button and the remove the mapping for required workspaces.

0

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

James Wierzba
  • 16,176
  • 14
  • 79
  • 120
  • This is not working for me. I'm getting the following error: An argument error occurred: One workspace name is required to delete a workspace. – Red M Jan 11 '18 at 14:02
0

If mapping is proper then you can undo/checkin your changes, if you really want to change folder name.

Alternatively if you want to remove mapping then in Visual Studio go to File-> Source Control-> Advanced-> Workspaces-> Edit

Now you can click on appropriate path and remove mapping.

Dharman
  • 30,962
  • 25
  • 85
  • 135