TFS Server checkin error - could not find file - Server Related and Command Line
Asked Answered
S

2

1

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?

Staley answered 8/2, 2019 at 20:38 Comment(1)
What do you mean “in the TFS Server”? Are you looking for the command line equivalents to what Visual Studio is doing but from the command line on the developers machine?Dyarchy
P
0

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.

Print answered 22/2, 2019 at 8:14 Comment(0)
M
0

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.

enter image description here

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.

Middlebrooks answered 22/2, 2019 at 9:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.