how to remove TFS workspace mapping for another user - tfs

I am using Visual Studio 2010. Some months back I was using some 'ABC' TFS user to connect to TFS and mapped some folders on my local drive. Now my previous user 'ABC' is gone and I am allotted a new tfs user 'XYZ' to connect to TFS. So naturally I tried mapping some remote folder to my existing local folder and I got the following error.
"The working folder 'Some_Local_Path' is already in use by the workspace WORKSPACE_NAME:USER_NAME on computer 'MACHINE_NAME'"
I have tried removing the cache folder contents but the same error (C:\Users{UserName}\AppData\Local\Microsoft\Team Foundation\3.0\Cache).
I have also tried running the commonly found TFS command (tf workspaces /remove:*) to delete the caches for all worksapaces but still the same error.
When I try to edit my workspace, it shows source control and local folders for my current user 'XYZ' but what I want is to remove the folder bindings for my previous user 'ABC'. How can I achieve that?

You need to get your TFS administrator to delete the workspace if you have no access to the account.
You may be able to do it by calling "tf workspace" with the explicit user specified, but you need "manage other users workspace" permission. TF Sidekicks uses the same commands so would require the same permission. It is a TFS admin productivity tool.
https://msdn.microsoft.com/en-us/library/y901w7se(v=vs.100).aspx
You can use:
tf workspace /delete "WORKSPACENAME;PREVIOUSUSERACCOUNT"

I had a similar issue and could not install sidekick because I'm running VS 2k17.
I was unable to delete the workspace because it kept telling me it could not find the workspace.
tf workspaces /computer:* /owner:*
This would list all of my workspaces and the owners. So I would try
tf workspace /delete myWorkSpaceName;Bob Smith
TF14061: The workspace myWorkSpaceName;Bob Smith does not exist.
That is the exact workspace and owner name I was getting in the original workspace listing above.
The solution was to ask for xml format
tf workspaces /computer:* /owner:* /format:xml > c:\temp\workspaces.xml
(Note: Output to file is optional, but recommended)
This gives workspace owner aliases and one of them was a long name with a guid and the account email. This finally worked:
tf workspace /delete myWorkSpaceName;aabe3ec12-1254-4956-b1ee-3fb26506931e\bsmith#myDomain.onmicrosoft.com
It asked for a confirmation and finally deleted my orphaned workspace.

If you have administrative rights to the collection you can use the TF command located in the Visual Studio\Common7\IDE directory to do this without having to install another tool.
First list the workspaces associated with the user:
TF workspaces /collection:"http://tfsserver:8080/tfs/collection_name" /owner:owner_id
This will return the list of workspaces owned by the user and computer they are associated with
To delete a named workspace:
TF workspace /delete workspacename;owner_id /collection:"http://tfsserver:8080/tfs/collection_name"

First of all you need to install TFS Sidekick (you can download it from http://www.attrice.info/cm/tfs/) In installation phase choose Integrated with IDE mode
Then a new menu will be added to Visual Studio as below
Menus -> Tools -> TeamFoundation Sidekick
Then open workspace sidekick
Search for the 'ABC' user and then you can delete his workspace

Open Source Control Explorer(View->Other Windows->Source Control Explorer)
On toolbar pane there will be Workspace combo. Choose from that combo Workspacess..
Edit
Remove

1.First we will check the list of workspaces from VS 2015 Developer command prompt,
Ex - tf workspaces /owner:*
2.Now we will get the xml format from VS 2017 Developer command prompt which will have ‘owner id’ for the particular workspace,
Example 1 - tf.exe workspaces /owner:* /computer:ComputerName /collection:https://YOUR-TFS-URL.visualstudio.com /format:xml
3.We can now delete the workspace for the particular user,
Example 1- Tf workspace /delete ComputerName;email#email.com /server:"https://URL.visualstudio.com"
OR
Example 2 - Tf workspace /delete ComputerName;1e178c77-bb8b-6f05-bf99
/server:https://URL.visualstudio.com
(Where 1e178c77-bb8b-6f05-bf99 is ID of the workspace which you get from Step 2 XML format)
4.Again we will check the list of workspaces from VS 2015 Developer command prompt,
Ex - tf workspaces /owner:*

Steps to delete workspaces from the TFS server:
Open Visual Studio Developer Command Prompt.
Goto Program Files (x86) folder, depending on the installed visual studio select "Microsoft Visual Studio 12.0" folder. Here this I have selected it because I am having Visual Studio 2013 installed on my machine. Add this path in the command prompt. Add like
"cd C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE"
Note: If you have an access of the TFS server from the network then you can try it from any machine where Visual Studio has been installed or from the same TFS machine server if it has Visual Studio there.
Check a list of workspaces under specific collection. Type below command to get the workspaces under one collection.
cd C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\tf workspaces /server:http://{TFSServername}:8080/tfs/{CollectionName} /owner:*
In the above command replace {TFSServername} this with your TFS servername or the Server IP.
In the above command replace {CollectionName} this with actual TFS Collection Name.
How to remove workspaces under specific collection. Check below command for the same.
tf workspace /server:http://{TFSServername}:8080/tfs//{CollectionName} /delete “{workspacename};{owner}”
Replace {workspacename} this with "Workspacename” which is there in the list of workspaces.
Replace {CollectionName} this with TFS Collection Name.
E.g. tf workspace /server:http://{TFSServername}:8080/tfs//{CollectionName} /delete {Enter Exact Workspacename};{Enter ExtactOwnerName}

I had the same issue that after deleting the workspace using tf delete command, I was getting the error that the workspace was already mapped! Then I found out tf delete workspace command leaves the job incomplete so you have to also delete it from the cache manually as was suggested here:
https://community.dynamics.com/365/financeandoperations/b/dynamicsaxinsightbyanas/posts/d365fo-the-path-is-already-mapped-in-workspace

I end up in same issue after the person who setup Jenkins left our company. He had setup workspace and TFS checkout was using alternate authentication. As his credentials are removed from msdn, TFS checkout started choking.
Following LarryG's solution helped to remove the workspace. Only difference is, I just used the windows live ID of the person, who left the company.
tf workspace /delete myWorkSpaceName;windowsliveID

Related

Delete TFS workspace mapping after jenkins job execution

I am trying to run a Jenkins job that uses TFVC plugin. We earlier had a problem with length of the TFS workspace names (exception for length > 75 chars). In order to address this we made a change in the TFVC configuration.
Default workspace name in TFVC: Hudson-${JOB_NAME}-${NODE_NAME}
After change: Hudson-${JOB_NAME}
Post this change the job had one successful run. We are unable to run this repeatedly as the TFS workspace created during the successful run was not deleted. and is throwing the following exception:
FATAL: hudson.remoting.ProxyException: com.microsoft.tfs.core.exceptions.TECoreException: The workspace scanAPI;tfsjenkins already exists on computer ip-XX-XX-XX-XX.
I have tried deleting the Jenkins workspace in pre/post build steps. This has no impact on the TFS workspace.
Additional information: The jobs are being run on a linux node and hence I am unable to run windows commands
You can use Post Build script that use tf.exe to delete the TFVC workpsace, with the delete command.
Create a global environment variable to be able to access the TF.exe easier. for example:
Note: the path to tf.exe it depend to which Visual Studio is installed in the Jenkins machine.
Add a Windows batch command from the scripts menu with the following command:
%TFS% workspace /delete /noprompt /collection:”https://tfs.codeplex.com:443/tfs/TFS27″ “Hudson-%JOB_NAME%;snd\7astlivec_cp”
Replace the URL with your TFS Server URL and change snd\7astlivec_cp with your TFS user. The command is going to delete the newly created TFS workspace.
Another option is to add tf.exe. location to the machine PATH variable and use it directly: tf workspace /delete .......
Update
For Linux, you should be able to use this through team explorer everywhere. It also include a tf command line.
Take a look at Setting up a workspace using Team Explorer Everywhere on Linux
Should be similar on Linux.
Instead of creating the default workspace by specifying workspace name in UI setting, you could also use a Windows batch command to handle this process.
If you want to delete workspace, just add a new post build step, a cleanup command could be added to delete the previously created TFS workspace.
%TFS% workspace /delete /noprompt /collection:"{your-tfs-team-project-collection-url}" "Hudson-%JOB_NAME%;{your-domain-user-name}"
More details your could kindly refer this step-by-step tutorial Jenkins Get Source Code By Specific TFS Changeset

Can't delete VSO workspace using tf.exe

I'm trying to map a VSO account to a folder on this PC, and based on team conventions we have to map it to C:\CompanyName folder.
Now when I try to map it, Visual Studio complains that:
The path C:\CompanyName is already mapped in workspace ComputerName;Windows Live ID\developerid
In previous instances of this error we would use tf.exe to remove the account like this:
tf workspaces
// showing list of workspaces, giving us the collection, workspace, owner, and computer
tf workspace /delete /collection:https://companyname.visualstudio.com workspace;owner
But it complains that:
TF14061: The workspace Workspace;Owner does not exist
Is there any other way to delete all workspaces from a machine? This is truly a painful, frustrating process.
When you delete a workspace, you should keep the owner same the it shows in tf workspaces.
Such as the ower name of a workspace is Jim Green, you should keep the blank space and quote the name with quotation marks, and delete the workspace by tf workspace /delete /collection:https://account.visualstudio.com workspace;"Jim Green".
Below is an example:
C:\hello>tf workspaces
Workspace Owner Computer Comment
-------------- ---------- -------------- --------------------------------------
mydev marina liu computername
C:\hello>tf workspace /delete /collection:https://marinaliu.visualstudio.com mydev;"marina liu"
A deleted workspace cannot be recovered.
Workspace 'mydev;marina liu' on server 'https://marinaliu.visualstudio.com' has
0 pending change(s).
Are you sure you want to delete the workspace? (Yes/No) Yes

How do I resolve error TF204017 that is preventing deletion of a workspace?

I am currently unable to delete a TFVC workspace on my local Windows 10 machine. It's a private workspace that I created. The machine is not domain joined and I am an administrator on the machine. I'm getting the following error:
D:\Projects\Active\SPE-DEV>tf workspace /delete MYWORKSPACE
A deleted workspace cannot be recovered.
Workspace 'MYWORKSPACE' on server 'https://ourcompany.visualstudio.com/defaultcollection' has 0 pending change(s).
Are you sure you want to delete the workspace? (Yes/No) y
TF204017: The operation cannot be completed because the user (Greg Enslow) does not have one or more required permission
s (Administer) for workspace MYWORKSPACE;Greg Enslow.
I get the same message if I try to delete it from within the Visual Studio UI. I can manually delete all the files and folders in the workspace but TFS recreates a the root folder with a hidden $tf folder.
This morning I uninstalled Visual Studio 2015 Enterprise (only had a trial license) and installed Visual Studio 2015 Professional (my company has a license for this). I'm sure this is a factor but my VS Team Services permissions haven't changed at all.
You can first change that MYWORKSPACE to be a public workspace, then run the "tf workspace /delete MYWORKSPACE" command again.
To change the workspace to be a public workspace, please go to Manage Workspace dialog, select the workspace and click Advanced.

Can't remove workspace from TFS

I want to add my project from Visual Studio 2012 to my TFS server, but it says the path is already mapped for workspace pc;administrator (this is a local workspace).
I have tried the command tool tf but it says that there are no workspaces, so I can't delete the workspace that is conflicting.
I'm running Windows 8 with Visual Studio 2012. TFS is on a windows server 2012.
The problem is that the current project location, the folder on your physical machine, is mapped to a different TFS server. To add it to source control you need to move it to a physical location not associated with a TFS server.
Edit
To remove the offending workspace:
1) Use the "Team" menu to connect to the TFS Server that you do NOT want to be mapped to
2) Use ctrl+q --> workspaces to access the workspaces menu
3) Remove the workspace
4) Change to the TFS Server you WANT to be mapped to using the "Team" menu again
5) ctrl+q --> workspaces
6) Add a new workspace
Try any of these steps out. Some of them may not be applicable to you.
To clear up "cached workspace" and remove workspace mapping.
On Control Panel > User > Credential Manager
Remove Windows Account and Generic Account that points to TFS.
How can I change the default credentials used to connect to Visual Studio Online (TFSPreview) when loading Visual Studio up?
On IE, remove cached password.
http://www.jayway.com/2012/12/17/changing-tfs-credentials-in-visual-studio-2012/
Remove stored username/password:
http://blogs.msdn.com/b/visualstudioalm/archive/2012/08/29/clearing-the-credentials-for-connecting-to-a-team-foundation-server.aspx
rundll32.exe keymgr.dll,KRShowKeyMgr
Delete workspace. On VS2012 command line, run the following:
tf.exe workspace /delete workspacename;owner /server:serveraddress
http://mycomputeradventures.blogspot.com/2012/01/removing-tfs-workspaces-from-old-users.html
Clear Up cached workspace mapping. On VS2012 command line, run the following:
tf.exe workspaces /remove:* (or /s:http//oldserver:8080)
http://blogs.msdn.com/b/buckh/archive/2006/09/12/path-is-already-mapped-in-workspace.aspx
if you use Visual studio 2012 go
C:\Users{UserName}\AppData\Local\Microsoft\Team Foundation\4.0\Cache
or if it is Visual studio 2013 go
C:\Users{UserName}\AppData\Local\Microsoft\Team Foundation\5.0\Cache
Remove all things under it.
Simplest way to do this is to go to your AppData and delete the TFS cache (depending on the version 3.0 or 4.0)
C:\Users{UserName}\AppData\Local\Microsoft\Team Foundation\3.0\Cache
or
C:\Users{UserName}\AppData\Local\Microsoft\Team Foundation\4.0\Cache
First we will check the list of workspaces from VS 2015 Developer command prompt,
Ex - tf workspaces /owner:*
Now we will get the xml format from VS 2017 Developer command prompt which will have ‘owner id’ for the particular workspace,
Example 1 - tf.exe workspaces /owner:* /computer:ComputerName
/collection:https://YOUR-TFS-URL.visualstudio.com /format:xml
We can now delete the workspace for the particular user,
Example 1- Tf workspace /delete ComputerName;email#email.com
/server:"https://URL.visualstudio.com"
OR
Example 2 - Tf workspace /delete ComputerName;1e178c77-bb8b-6f05-bf99
/server:https://URL.visualstudio.com
(Where 1e178c77-bb8b-6f05-bf99 is ID of the workspace which you get from Step 2 XML
format)
Again we will check the list of workspaces from VS 2015 Developer command prompt,
Ex - tf workspaces /owner:*
Well I couldnt find my troublesome workspace, which prompted me to copy the local code folder into another name and I created a new workspace mapping that folder.
Next up I added the new solution to the TFS via VS 2012 using Add Source Control.

Team Build Error: The Path ... is already mapped to workspace

When creating a new build in Team Foundation Server, I get the following error when attempting to run the new build:
The path
C:\Build\ProductReleases\FullBuildv5.4.2x\Sources
is already mapped to workspace
BuildServer_23.
I am unable to see a workspace by that name in the workspaces dialog.
Use the command line utility TF - Team Foundation Version Control Tool (tf).
You can get a list of all workspaces by bringing up a Visual Studio Command Prompt then changing to your workspace folder and issuing the following commands:
C:\YourWorkspaceFolder>tf workspaces /owner:*
You should see your problem workspace in the list as well as it's owner.
You can delete the workspace with the following command:
C:\YourWorkspaceFolder>tf workspace /delete /server:BUILDSERVER WORKSPACENAME;OWNERNAME
Just delete the contents of the following folder(s):
C:\Users\UserName\AppData\Local\Microsoft\Team Foundation\3.0\Cache
Where UserName is actual or current user, and 3.0 is the version number.
I had a similar issue and to remove the workspace that was causing me a problem, I logged into another machine with TFS client installed and performed the following:
On the File menu, point to Source Control, Advanced, and then click
Workspaces....
In the Manage Workspaces dialog box, tick the Show remote packages checkbox.
Under the Name column, select the workspace that you want to remove, and then click Remove.
In
the Confirmation dialog box, click OK.
I received this error, which was caused by having two build definitions that pointed to the same source. The issue was that I used a static build directory in the Build Agent.
This forum post describes my issue and resolution exactly:
http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/60a4138a-9b28-4c46-bdf4-f9775ce43c3e/
We had the same problem but deleting the workspace's from the TFS server did not work.
(I should mention that I grabbed my colleagues VM that was already set up with his credentials.)
For me this worked:
http://blogs.msdn.com/b/buckh/archive/2006/09/12/path-is-already-mapped-in-workspace.aspx
I just went into the : ...\Local Settings\Application Data\ made a search for VersionControl.config, opened up the folder that contained this file and deleted all of it's contents.
Previous to that I tried manually editing the file but it continued with the same error message.
I hope this helps.
For some reason I was having trouble deleting the workspace from the command-line utility. Luckily I found Team Foundation Sidekicks 2010 (from this post) which is free and provides a GUI for viewing and deleting TFS workspaces, and many more useful TFS features.
I had a similar problem with Visual Studio 2010 complaining about an already-mapped-workspace, but instead of deleting the entire workspace, I used the following from the Visual Studio Command Prompt: "tf workspace PROBLEM_WORKSPACE_NAME". This brought up an "Edit Workspace" dialog. From there I was able to remove the path in question from the "Working Folders" list, which got rid of the error.
the rest was fairly easy.
Simply go to this folder:
C:\Users{UserName}\AppData\Local\Microsoft\Team Foundation\4\Cache
and delete all that's in the folder.
I was getting an exception telling me that the file was already mapped in another workspace:
"The path {File Path} is already mapped in workspace {Workspace Name}."
This workspace was deleted beofre.
With the help of friend of mine I found out that TFS save workspace info under the user local settings dir. We found a file named:
VersionControl.config under {User Documents and Settings dir}\Local Settings\Application Data\Microsoft\Team Foundation\1.0\Cache.
This file contains all the local mapping of TFS. Probably when you use the Map method and don't use:
public void DeleteMapping(WorkingFolder mapping); before deleting the workspace the mapping information is not removed from this file which is used by TFS to check if you've alreay mapped a specific path.
To resolve this problem delete all the keys from the config file. Don't delete the file because you'll get it again from the server cache.
Here is what I did (well what I do):
Using TFS Sidekicks clear out the user and server filters so they are blank. This will let you get all workspaces.
Check the build error for the workspace name. In the OPs case it is BuildServer_23. It is different in my environment but basically just match up the error name with the one in the tfs sidekick list.
Click the red x to delete the workspace.
Viola!
If applicable, you can also clone the build definition and change its name. This workded for me.
I tried all the following solutions such as :
Use sidekicks to delete WS.
Use tf commands to delete remote server workspaces.
Delete the TFS cache folder.
The following worked for me:
tf workspaces /remove:*
If you don't have permissions on the server to delete other people's workspaces, you can just change the name of the build definition. TFS will create a new workspace and map it to "C:\Build\ProductReleases\new build name here\Sources".
While trying to 'Get latest version' of a project which I had previously mapped to a local directory and then deleted, I saw this same error message.
First I tried the SideKick tool and then the Visual Studio 2010 command prompt, both of which told me I had no workspaces mapped.
Next I searched for 'VersionControl.config' within c:/users/myuser/appdata, and deleted the 4 references it found.
I re-opened Visual Studio and I was able to re-map the project, no more error!
Simplest way to do this is to go to your AppData and delete the TFS cache (depending on the version 3.0 or 4.0)
C:\Users{UserName}\AppData\Local\Microsoft\Team Foundation\3.0\Cache
or
C:\Users{UserName}\AppData\Local\Microsoft\Team Foundation\4.0\Cache
TDN's solution worked for me when I was having the same issue. The Build server created workspaces under my account. Checking this box allowed me to see and delete them.
I got same issue in Visual Studio 2017 and TFS 2017. DefaultCollection must be mapped first to you local path. Somehow this step was skipped and I got only MyFirstProject mapped.
All you need to do is:
- 1. Go to your TFS web page and remove the project from the server.
- 2. Remove the project from your local "Worksapces"
- 3. Go to "Manage Connections" which will refresh your Home page in TeamExplorer.
- 4. You will get Configuration page which will allow you to setup root path to your DefaultCollection.
- 5. You should get message that it been done successfully. Now you can create your project.
It's important to map root of your collection to your workspace first and then map a new project.
My issue was related to using multiple accounts. This is how I was able to switch accounts.
Open Team Explorer
From the big drop down menu near the top of the pane...
Navigate to:
Projects and my Teams>Manage Connections
Navigate to:
Manage Connections>Connect to Team Project
Use the "Switch User" link to switch accounts.
Now the workspace names will match the chosen account.
I couldn't get any other solution to work.
I had a new account created and the old account no longer had permissions (both on same machine).
I tried:
1) Deleting the workspace (couldn't see in VS with or without remote workspaces checked)
2) Deleting from the command line
3) New owner command
4) Deleting the cache
So I simply opened VS as admin and mapped to a different folder.
Deleting the workspace and cache was not sufficient for me.
I had to also restart the "Visual Studio Team Foundation Build Service Host" service.
Go to the Source Control Explorer
In the toolbar there is a dropdown list of Workspaces.
Click the dropdown and go to workspaces.
Remove the unwanted workspace.
Map to your local.
I changed
Build Definition -> Workspace -> Build Agent Folder
from
c:\some\path
to
$(SourceDir)
and it fixed the issue.
I had this issue with this with Azure DevOps automated builds in an on-prem TFS build agent. Removing the workspace using TFS Sidekicks did not work. And tf.exe could not even find the workspace to delete it.
This solution should work for TFS 2017, TFS 2018, Azure DevOps, and possibly other versions:
Take note of the workspace GUID in the error message.
On the machine where the build is taking place, navigate to: %USERPROFILE%\AppData\Local\Microsoft\Team Foundation\ (where %USERPROFILE% belongs to the user that triggered the build).
Search for and remove all instances of the workspace GUID under that directory. There will likely be a folder in a 'cache' directory, as well as entries in 'LocationServerMap.xml' and 'LocalItemExclusions.config'. Remove them all.
That worked in my circumstance.
Simply delete the workspace:
workspace /delete "the-workspace-name"

Resources