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:
- A Branch operation was first executed to move an existing Solution+Projects to a new location in the TFS repository.
- 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.
- 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
- Delete all source code from disk.
- Start Visual Studio.
- Open the Source Control Explorer window
- Workspace dropdown => Workspaces => select
MyWorkspace
=> Edit... => Advanced- everything looks good
- Ensured that there are no TFS pending changes related to the solution's projects.
- Source Control => Get Latest
- Opened the solution (e.g.
MySolution.sln
) in Notepad++ - Deleted the entire section:
GlobalSection(TeamFoundationVersionControl) = preSolution
- Saved the solution file.
- Opened the project file (e.g. MyProject.vcxproj) in Notepad++
- Deleted the following XML elements:
SccProjectName
SccAuxPath
SccLocalPath
SccProvider
- Saved the project file.
- Visual Studio => File => Open => Solution
- Clicked on the
MySolution
in Solution Explorer - File => Source Control => Advanced => Change Source Control
- In the status column,
MySolution
andMyProject
are listed asNot Controlled
- In the status column,
- Clicked
MySolution
and Bind - Clicked Ok. So far so good.
- File => Source Control => Advanced => Change Source Control
- In the status column,
MyProject
is listed asNot Controlled
- In the status column,
- Clicked
MyProject
and Bind- In the status column,
MyProject
is now marked asInvalid
- In the status column,
- 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."
- Click: Fix server bindings
- Dialogue window disappears.
- Click: Ok
- The previous error re-appears.
- 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.
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 ofInvalid
: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 toValid
.