Can't delete VSO workspace using tf.exe - tfs

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

Related

Not able to Map Workspace in local folder using VS 2017

I was trying to map workspace, due to some issue I have canceled the process and deleted the entry from Manage Workspace.
But when I retried the process, I am getting below error
"The workspace [workspaceName];[Owner] already exists on computer [ComputerName]"
I have tried below things to resolve it
1) using VS Command prompt
First display list of workspaces for named computer giving workspace name and owner:
>tf workspaces /computer:oldComputerName /collection:”http://devsrvr:8080/tfs/DefaultCollection”
To delete:
>tf workspace /delete WorkSpaceName;OwnerName /collection:”http://devsrvr:8080/tfs/DefaultCollection”
But listing command is not showing any workspace. so this option dosen't help me.
I got the help reference form here
2) Tried Repair Local Visual Studio TFS Workspace Mapping by clearing cache data from %localappdata%\Microsoft\Team Foundation\5.0\Cache. This option also didn't work for me. I am still getting same error. Reference
3) Checked Control Panel >> User Account >> Mange Password for deleted the enetries (It is used to work with older VS version). But this also didn't work.
Please let me know if any one know the resolution.
You may try the items below:
Close VS.
Removes the specified workspace entry with the command line: tf workspaces /remove:(*|workspace1[,workspace2,...]) /collection:(*|TeamProjectCollectionUrl)
Delete the workspace with command tf workspace /delete [/collection:TeamProjectCollectionUrl] workspacename[;workspaceowner] [/login:username,[password]]
Create a workspace with new name and then retry deleting the old workspace.

Copy source files to other TFS

We have a TeamCity/Octopus setup that runs great for several projects.
A new client wants access to the source code during development. Is it possible to copy code from our TFS to an other TFS using TeamCity? It does not need to be real-time. Daily copies are OK.
Not sure if we should use TeamCity for this or if there are possibilities within TFS itself.
You could setup a daily build schedule and use the TFS command line utilities to transfer the files to another server. You'll probably get all kinds of sync issues along the way, unless you always take your own solution as the current situation.
Look at tf.exe, especially the workspace, workfold commands and add, delete, and optionally destroy. Complete the job with a tf checkin.
Process as follows:
Create a workspace on your source TFS server (or use the built-in workspace features in team city): tf workspace /new
Map the folders you want to share: tf workfold /map
Get the files to the machine that's doing the transfer: tf get /recursive
Create a workspace on your target TFS server: tf workspace /new
Map the folders you want to share to tf workfold /map to a new folder that's not mapped to the source TFS server.
WS2 delete the files in the target folder: tf delete * /recursive
WS2 Check in to make sure you won't get any conflict remotely: tf checkin /recursive
WS1 -> WS2 Copy the files from the first workspace to the second: xcopy
WS2 Add all files: tf add * /recursive
WS2 Checkin all files tf checkin * /recursive
WS2 & WS2 Delete the workspace: tf workspace /delete
(Optional) Delete the files in the folders of the deleted workspaces on disk.
PS: if you move to git, this all becomes a lot easier, since the distributed nature of git is kind of meant for scenarios like these.

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.

how to remove TFS workspace mapping for another user

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

Phantom TFS workspace will not let me map to another workspace?

I type this command: tf workspaces into a command line and it tells me there are no workspaces on the machine. I then try the same command on the server, nothing. So I go into Visual Studio 2010 and create a new workspace and try to map the TFS path to my local path. I then get an error that the mapping already exists in another workspace. But I cannot find that workspace on my local or on the tfs server. Any ideas?
You can run tf workspaces /remove:* to clear out your local cache of workspaces. See this link for more details.
I know this is an old question, but I just came across this issue on a Linux machine running TEE (Team Explorer Everywhere). Running "tf workspaces -remove:*" didn't work, because it said there were no workspaces in the cache.
The user was trying to create a new workspace, which worked, but when he tried to map folders, it told him it didn't exist.
When he ran "tf workspaces" on the machine and when I looked in TFS Sidekicks on the server itself, it didn't show any workspaces for him on the Linux box.
If he tried to create the workspace again, it told him that it already existed, but every time he tried to map, he was told it didn't.
We could see the workspace from the tf command line if I did "tf workspaces /owner:", and it required me to run "tf workspace /delete ;" from the command line to get rid of it.
Once we did that, he was able to create it again and everything worked properly.
No idea why that happened, but figured I'd post my answer here just in case someone else comes across a similar issue in the future.

Resources