Re-establish TFS source control bindings

Solution 1:

You say you've tried undoing the binding, but have you tried rebinding back to source control?

In Visual Studio:

  • Open a solution with the problem
  • Choose the solution in Solution Explorer
  • Pick File->Source Control->Change Source Control
    Visual Studio 2013/2015: File->Source Control->Advanced->Change Source Control
  • Unbind any projects that are bound but not working correctly.
  • Bind all projects that are now unbound.

Solution 2:

When you have an invalid binding and unbinding/binding a project doesn't work, try the following:

  1. Unbind project in Change Source Control
  2. Unload project in Solution Explorer (For a website-project 'unload project' is not in the context-menu but in the 'Website' menu)
  3. Reload project in Solution Explorer

Works for me all the time...

Solution 3:

I agree with Joel - usually unbinding and rebinding fixes it.

However, if rebinding doesn't work, you might try editing the solution files directly. I have seen instances where TFS bindings are in the solution file twice and appear to be inaccurate for whatever reason - They may have the wrong number of projects and projects that are set to nothing but still listed in the solution file.

When this happens (pretty rare) I edit the files and make them the way that they should be. For example, I will delete out the 2nd set of TFS bindings (GlobalSection(TeamFoundationVersionControl) or fix any other discrepancies that I see. Then I reload the solution and that normally fixes the problem. I would definitely only use that fix as a last resort though.

Solution 4:

I saw this problem the first time I opened an existing (and previously working) solution in a newly installed Visual Studio, with a newly made Workspace.

Unbinding and rebinding didn't fix the problem for me. But it went away when I did a Get Latest Version. TFS showed the files as conflicted, and I resolved the conflicts by overriding the local copy. The previously invalid bindings were then shown as valid.

Solution 5:

If your're still fighting with TFS binding invalid status I report here a "gem" I've found in an old (2005) MSDN forum (https://social.msdn.microsoft.com/Forums/en-US/801b2490-776d-43a8-afef-adcedd78f02d/vsts-change-source-control-status-invalid?forum=tfsgeneral):

This is due to a heuristic used in the validation code for binding. The heuristic does an existence check for all of the files in the project and will only return "valid", if at least half of the files are present in the source control repository. Since web projects have no project file, any file residing in the web project folder is considered "part of the project". Apparently you had enough uncontrolled files to tilt the percentage of controlled project files to under 50%, thus causing an invalid status.

In other words, if you have a project that has many files uncontrolled (this is especially true when you opt-out check-in for folders like node_modules or public in a web project) and the number of these files are more than 50% of the total files in the folder, TFS binding status are invalid whatever you do.

I could verify this rule just removing the correct number of files until the binding status became invalid and just adding a new one (uncontrolled) get the invalid status.

This behavior is still present in VS 2019 6.3 (Azure DevOps).

I don't know if there is a way to disable this heuristic, but I'm pretty sure that it's a fake Invalid status, i.e. tfs binding is actually working correctly and that is just an erroneous message.