Re-establish TFS source control bindings

2019-01-10 20:12发布

问题:

I have about a dozen Visual Studio 2010 projects I've been working on that are versioned in a TFS repository. Recently I went on a vacation and upgraded my computer's OS to Windows 7 64 bit.

I've reinstalled Visual Studio, and I can connect to my Team Foundation Server and see my projects...only my bindings aren't working correctly. Most of the time none of my files seem to be under source control, but in a couple of projects my source control bindings are OK in the root folder, but not working in subfolders off the project root.

I've tried undoing the binding, opening from source control, and deleting the folder and doing a get latest version. None of these has fixed the problem.

Any thoughts on restoring my bindings?

UPDATE

After poking around I can see there seems to be an extra folder in the path of my "invalid" projects...I've got no idea how it got in there, but this seems to be throwing off my mappings.

回答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.


回答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...



回答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.



回答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.



回答5:

When I renamed my solution, I ran into this error as well. I tried all of the above and it did not resolve the situation.

Actual Solution for me was to edit the Build Definition with the new Solution Name

  1. My Builds > Right Click the Build Definition > Edit my Build Definition > Process
  2. Note that "1. Required > Solution to build" is referencing the old Soluton name.
  3. Click the "..." beside the "Solution to Build",
  4. Find your new solution. Click it
  5. Save the Build Definition
  6. Rebuild


回答6:

Had exactly the same issue but then within visual studio 2017.

Unbinding and rebinding didn't work for me. In then end I solved it by unbinding all the projects in the soluting + the solution file itself and thereafter doing a 'Get Latest Version' for the entire branch. This resulted in a series of conflicts: 'A non version controlled file or writable file by the same name already exists locally'. Resolved those errors by choosing the 'Overwrite Local Filer or Folder Option' Finally this solved it for me



回答7:

Make sure that you solution is already added to source control: File > Source Control > Add Solution to Source Control.