TFS Server checkin error - could not find file - Server Related and Command Line - tfs

This relates to question,
TFS checkin error - could not find file
"When checking in my project I get the error:
Could not find file 'C\blah blah blah'.
I have a feeling this might be a file from an old project I deleted.
I have tried deleting my TFS connection and workspaces.
The Solution was:
This will happen when TFS has some changes staged that no longer exist on the file system. For instance, if you add some files in Visual Studio (which adds them to the changes list), delete them directly from the file system, then attempt to check in the changes, it will complain that it could not find the file(s).
To remove these changes from the list, you can open Source Control Explorer (View > Other Windows > Source Control Explorer) and either Delete the nonexistent files or right-click on the offending files and Undo Pending Changes.
You can also undo these specific changes from the Pending Changes panel in Team Explorer.
Follow up Question:
So my question is,
how do I conduct the equivalent of this in the TFS Server? It continuously happens multiple times on our team.
This works on a person's desktop, but whats the equivalent commandline in the TFS server, and can I incorporate this in my build steps?

You delete files from TFS in the wrong way. the TFS server doesn't know your local file system, if you deleted a file from your local folder the file still exists on TFS.
This is the reason for the issues and errors. if a developer wants to delete a file and he deleted the file from the local folder and then got the error Could not find file and to solve it he does "Undo pending changes" so the file still exists on TFS and when another developer see the file in his system he also deleted it locally and he also will get the error in the check-in.
So, if a developer wants to delete a file from TFS he needs to right-click on the file and "Delete" and "check-in". if he already deleted it locally he can do the "delete nonexistent files" and "check-in". now each developer when he does "Get latest" not will get the file.
You can also delete files with a tf.exe command line in the delete command:
tf delete [/lock:(none|checkin|checkout)] [/recursive] [/login:username,[password]] itemspec
During the build, you can add a command line/Power Shell task and run the tf.exe.

You can undo another person's changes from the commandline using:
tf vc undo /workspace:workspacename;owner $/project/path/to/file
You can get this information by calling:
tf vc status $/project/path/to/file /user:*
This allows you to remove pending changes from the server, though it won't cause the files to be reverted on the workstation of the developer in question.
Both commands offer a /recursive option to undo multiple files under a specific path at once.
If you're using Visual Studio 2015 or earlier, then you can use the TFS Power Tools to add a "Find by status" option to the Visual Studio Source Control Explorer. This has unfortunately not made it into Visual Studio 2017 and there are no TFS Power Tools for Visual Studio 2017.
The TFS Sidekicks offer a Status Sidekick screen, which allows you to query all files currently checked out for edit in server workspaces and allow you to undo them centrally.
Preventing the issue altogether
To prevent the issue altogether you have a few options. You can switch to Local workspaces, instead of server workspaces. Those auto-detect local changes and don't register changes on the TFS server itself. Read more about local workspaces.
You can perform the deletes from the tf vc command line instead of using other tools to delete files and folders, for example:
tf vc delete $/project/path/to/file
The delete command also has a /recursive option. Using this command will not only update your local folder, but will also update the server workspace.

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.

check in assembly info in CI with tfs

how i can check in assembly info in tfs?
i am using tfs CI and i have one work space, when i try to check in pending :
2017-09-10T17:37:40.3410618Z No files checked in.
2017-09-10T17:37:40.8732772Z There are no pending changes matching the
specified items.
changes, tfs log show no pending change, but my dll version is right.
i can see assemblyinfo files in visual studio pending changes.
i am using assemblyinfo plugin in CI and i am check in with powershell command:
Tf.exe checkin $/[path]/assemblyinfo.cs
When you build in VS locally, the file assemblyinfo.cs generated within the workspace (the project in source control mapped) and will be detected automatically in Pending Changes page.
But according to your description, you build with TFS, that means the file assemblyinfo.cs is not in source control yet. Unless you publish/add the output to the active workspace just like build locally with VS, then you can check in directly. Otherwise you have to add the file to source control first, then check in.
So, just try to run "tf status" command first, it will show you list of pending changes.
tf stat /collection:http://server:8080/tfs/Collection
If that file not been listed, just run tf add first, then tf checkin (You need to change directory to your mapped folder first)

How do you delete an outstanding TFS team project root directory?

How do you delete an outstanding TFS team project root directory?
The team project, MyProblemProject, has been deleted from TFS, but my local file system still has the root directory.
If I delete my local directory, C:\Dev\MyProblemProject, Visual Studio flags the delete as a pending excluded change. But if I try and promote the delete change, I get the error ...
TF101069: Unsupported pend change attempted on team project $/MyProblemProject. Use the Project Creation Wizard in Team Explorer to create a project or the Team Project deletion tool to delete one
Tried using tfsdeleteproject but it gives a TF200016 The project does not exist
So how can I delete the local directory and not have Visual Studio see it as a delete change?
... and why does VS still think the directory is in TFS, as I can't see the MyProblemProject?
It's possible you didn't completely delete your project in TFS server.
Then your local directory still have some source control bindings. This is why VS still detected the changes.
However, there is a workaround for this situation -- remove the bindings of your local mapping folder. Change Bindings on TFS project
If it still doesn't work, sometimes, the binding info is cached. Try to delete TFS cache by going into default C:\ {User Profile Folder}\AppData\Local\Microsoft\Team Foundation\5.0\Cache and VS cache in appdata folder.
Moreover, we usually delete team project in TFS through below two ways:
Delete it in TFS Administration Console
Use tfs command
TfsDeleteProject /collection:https://xxx.8080/tfs/DefaultCollection MyProject

TFS 2012 Unshelve to different branch -> An item with the same key has already been added

I need help resolving the following issue:
I am attempting to unshelve code from the source branch onto a target branch.
I am using the following:
VS2012 RC
TFS 2012
VS2012 x64 Cross Tools Command Prompt
When I use the command prompt to perform the unshelve operation, the following occurs:
Shelveset details dialog gets displayed with list of change files.
Click Unshelve button.
Observe command prompt output: "An item with the same key has already been added."
I have downloaded ServicePack1 for power tools.
However, I have failed to resolve this issue.
I had the same issue and fixed it when I re-shelved the changeset from the source branch but chose not to preserve pending changes locally. After this the migration of the new shelveset ran smoothly.
(I also made sure I'd followed the below steps collected from other answers on this site)
Use a workspace that encompasses both source and target branches
Run the command from the folder mapped to the source branch
Check for quotes around any paths containing spaces
Deleting the cache in C:\Users[USERNAME]\AppData\Local\Microsoft\Team Foundation\4.0\Cache and restarting Visual Studio
I had the same error when using Visual Studio 2013 and the following command:
> tfpt unshelve /migrate /source:"$/Root/Solution" /target:"$/Root/Branches/Solution" "The name of my shelveset"
> An item with the same key has already been added
Research
Here's what I tried to fix the issue:
Clearing the Cache as per Andrey's answer
Try running the command from the Source -> Branch and Branch -> Source
My workspace already encompassed both source and target branches
Solution
Open up your equivalent of the VS2013 x86 Native Tools Command Prompt.
Check you have Team Foundation Power Tools installed:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\tfpt
Ensure you have 0 Pending and Excluded changes.
I had some Excluded changes which were detected but not added and this is what caught me out. Excluded changes should look like this:
Note: No "Detected: XX (adds)" - should not be visible
When you run tf status, you should see something like the following.
Either 1 change(s) for the .tfignore file or 0 change(s). Anything else will upset the merge.
C:\tfs\Root\Solution>tf status
File name Change Local path
$/Root .tfignore edit C:\tfs\Root\Solution.tfignore
1 change(s)
Ensure you are running the tfpt command from the source Solution directory
You should be now be able to successfully merge a shelveset from one branch to another.
Note on .tfsignore:
If you have a lot of pending changes that you don't want to undo for whatever reason, then
a modification to the .tfignore file is ok.
If this is the only file that you have left with changes, it won't brake the merge.
.tfignore reference => stackoverflow - How to ignore files/directories in tfs?
Try to undo all changes on Source and Target branch and then try again...
Try to delete all the files in the following folder and restart VS2012 (Source):
C:\Users[USERNAME]\AppData\Local\Microsoft\Team Foundation\4.0\Cache

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