tf.exe workspaces "Unable to determine the source control server" - tfs

I am getting the following message from the build server:
System.Web.Services.Protocols.SoapException: The working folder C:\TFSBuildAgent\_work\8\s is already in use by the workspace ws_8_18;Project Collection Build Service (TEAM FOUNDATION) on computer MYSERVER02.
at Microsoft.TeamFoundation.VersionControl.Server.Repository.CreateWorkspace(Workspace workspace)
I have logged onto Server MYSERVER02 and am trying to delete the workspace ws_8_18 by running one of the documented commands for tf.exe workspaces:
tf.exe workspaces remove:*
tf.exe workspaces remove:ws_8_18
tf.exe workspaces remove:ws_8_18 /collection:"http://myserver/projectcollection"
None seem to work and I get the error message:
Unable to determine the source control server.
How do I do it correctly?

The correct syntax is:
tf.exe workspaces /collection:"http://myserver/projectcollection" remove:ws_8_18
i.e ensuring the project collection comes before the remove command.

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 run some TFS commands

I am trying to change the owner of a TFS Project Collection with this command:
tf workspaces /collection:http://appdev:8080/tfs/applications applications;OLD.OWNER /newowner:NEW.OWNER
But I am getting this error:
Unrecognized command option 'newowner`
I also tried with workspace instead of workspaces as suggested by Giulio, but with this error:
The workspace applications;OLD.OWNER does not exist. Please specify an existing workspace or /new to create one.
Also tried adding a /computer:COMPUTERNAME switch, but this gives the same error as the previous attempt.
Interestingly, when I try querying all workspaces with
tf workspaces /collection:http://appdev:8080/tfs
I get:
Unable to retrieve the registration information for 'ISCCProvider'
And the same error is produced if I specify the computer
I am running this command from the Developer Command Prompt for VS2015, but not on the TFS server itself (I am running it from my machine).
I am the owner of all project collections.
I am able to call tf workspaces without any issue, and I can also call tf workspaces /collection:http://appdev:8080/tfs/applications with the expected results.
What could possibly be going wrong here?
When you typing
tf workspaces /collection:http://appdev:8080/tfs
You will definitely get this error
Unable to retrieve the registration information for 'ISCCProvider'
Since this command tf workspaces it's collection level not server level, your address (http://appdev:8080/tfs) is server url, you just need to add your collection info of the url such as http://appdev:8080/tfs/applications The error will disappear.
In your case :
First typing
tf workspaces /collection:http://appdev:8080/tfs/applications
This will list all workspaces belongs to you on your computer.
Then typing
tf workspace/collection:http://appdev:8080/tfs/applications workspacename/newowner:xxx
The workspace name is the one which you want to change the owner.
You can get the info from the first command. You don't have to add
the older owner name and option, just need to add new owner
name.
Finally you cloud also typing
tf workspaces /collection:http://appdev:8080/tfs/applications
again, you will see
the changed workspace will not list any more. This is make
sense, since the owner is changed and the workspace not longer
belongs to you.
Mind the spelling: you want tf workspace but you typed tf workspaces which is a different command.
tf workspace and tf workspaces command is used to set/configure the workspaces, and the command used to change the owner of the workspace is:
tf workspace /collection:http://appdev:8080/tfs/collectionname workspacename;oldowner /newowner:newowner
You cannot use this command to change the settings for project collection.

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

TFS command line to get all mapping information of a specific workspace

I am trying get all maping information for a specific workspace.
When I try this command, it displays a dialog - which is not what I want.
tf workspace myworkspace
Is there a command that will get all the working folder information and output to the console?
The following command displays the working folder mappings for the workspace in the current directory:
C:\projects>tf workfold
If you want to list the working folder mappings for a different workspace, you can specify the /workspace:workspacename parameter.
C:\>tf workfold /workspace:My_Other_Workspace
You can manipulate the workspace mappings using this command also.
The following example maps the folder C:\DifferentWorkfold to the Team Foundation version control server folder $/projects/project_one
c:\projects>tf workfold $/projects/project_one C:\DifferentWorkfold
See Tf Command-Line Utility - Workfold Command on MSDN for more information
In TFS 2008 and TFS 2010, the command
C:\projects>tf workfold
would indeed display the working folder mappings for the workspace in the current directory.
However, for TFS 2012, this command no longer works.
Now, you just get an error message:
Unable to determine the workspace. You may be able to correct this by
running the command 'tf workspaces /collection:TeamProjectCollectionUrl'
If I knew the TeamProjectCollectionUrl then I wouldn't need to run the workfold command!

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