HowTo: change a project's status from `Invalid` to `Valid`?

5.2k views Asked by At

With respect to Team Foundation Server's (TFS) source control... how do you change a project's status from Invalid to Valid?

Background

We are in the process of reorganizing several solutions & projects in TFS. In this case:

  1. A Branch operation was first executed to move an existing Solution+Projects to a new location in the TFS repository.
  2. The project hierarchy was a mess, so I used the TFS Move operation to move the projects to an appropriate location.
    • This step was performed on a number of projects. For 99% of them, the binding is ok.
  3. The changes were then committed to TFS.

Different Approaches

One

In Visual Studio...

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

Two

  1. Delete all source code from disk.
  2. Start Visual Studio.
  3. Open the Source Control Explorer window
  4. Workspace dropdown => Workspaces => select MyWorkspace => Edit... => Advanced
    • everything looks good
  5. Ensured that there are no TFS pending changes related to the solution's projects.
  6. Source Control => Get Latest
  7. Opened the solution (e.g. MySolution.sln) in Notepad++
  8. Deleted the entire section:
    • GlobalSection(TeamFoundationVersionControl) = preSolution
  9. Saved the solution file.
  10. Opened the project file (e.g. MyProject.vcxproj) in Notepad++
  11. Deleted the following XML elements:
    • SccProjectName
    • SccAuxPath
    • SccLocalPath
    • SccProvider
  12. Saved the project file.
  13. Visual Studio => File => Open => Solution
  14. Clicked on the MySolution in Solution Explorer
  15. File => Source Control => Advanced => Change Source Control
    • In the status column, MySolution and MyProject are listed as Not Controlled
  16. Clicked MySolution and Bind
  17. Clicked Ok. So far so good.
  18. File => Source Control => Advanced => Change Source Control
    • In the status column, MyProject is listed as Not Controlled
  19. Clicked MyProject and Bind
    • In the status column, MyProject is now marked as Invalid
  20. If I now click ok, the following error is displayed:
    • "Some projects have been bound to server locations that may be incorrect. A location may be incorrect either because it does not contain the majority of the projects' files or because those files are not in the correct location relative to the specified server folder. You should probably fix all the bindings in the solution. However, you may continue and bind these projects to the specified locations even when some may be incorrect."
  21. Click: Fix server bindings
    • Dialogue window disappears.
  22. Click: Ok
    • The previous error re-appears.
  23. Click: Continue with these bindings
    • The Dialogue window disappears, but I am still no further to solving this problem :(

Environment

  • Visual Studio Premium 2013 (v12.0.21005.1 REL)
  • Windows 8.1 Enterprise (64-bit)
  • This solution contains several other projects (C++ & C#), and the binding is fine.
  • This solution does not have a build definition at this time.

Additional Reading

3

There are 3 answers

0
Pressacco On

Typically I avoid checking in code that is not [1] compile-able, and [2] ready for production (or at least ready for QA).

In this case, I decided to ignore my own rule and now I have paid the price :(

The Solution

Although the projects location had been properly changed using the TFS Move command, a few C++ projects had references pointing to the old paths. As a result, these projects had a Binding status of Invalid:

  • The project Filter included a file that was no longer in the old location.
    • MyProject => ThirdPartyLib filter => HeaderOfSomeLibraryFile.h
  • MyProject.vcxproj had an invalid project reference.
    • MyProject => Properties => Common Properties => References

After these problems had been corrected, the MyProject.vcxproj binding status automatically switched to Valid.

0
ChrisTorng On

I found two solutions:

  1. Unbind, unload project then reload. Comes from Binding Invalid.

  2. Delete the files that are not in source control. Comes from Solving the "Some projects have been bound to server locations that may be incorrect." in Visual Studio 2010 when using Team Foundation System 2010: When some percentage of Solution Items cannot be found locally, and are not in the version control system, Visual Studio marks the solution binding to the version control system as "Invalid".

For my case, it's because Angular build generate many files that I use .tfignore to stop them from being check-in. Visual Studio 2019 found "it does not contain the majority of the projects' files" and mark that project as "Invalid". After delete those files, it become "Valid" automatically. So the "Invalid" state is just a misleading/useless warning. You can just ignore that warning as nothing is really "invalid".

0
bkjensen On

I ran into the same problem a today. After trying different approaches, I found out, that two files in the current solution, was ignored (They were not added to TFS repo). In my case I had 2 custom ".config" files.

After adding these files manually, the status changed to 'Valid' and binding is now working.