Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid bindings in Visual Studio 2019

I'm aware that this is a very commonly asked question as it seems to happen to a lot of people. I'm posting this question to see if I have any options when all the suggestions I found to resolve the issue have failed.

I have a solution with 6 projects that I work on using Visual Studio 2019. Everything was working fine and all of a sudden, it looks as if my solution is not under source control. All the binding are showing Invalid and trying to fix them is not working.

The only thing that I did that may have caused the issue was to upgrade VS 2019 to the latest version i.e. 16.2.5 when it became available the other day. Prior to the update, I was using VS 2019 16.2.4. Other than that, nothing has changed nor have I done anything unusual.

My question is what options do I have after all the suggested approaches I found on the Internet have failed?

Here's what I've tried so far and nothing's worked:

  1. I deleted the .vs folder and opened the solution. Didn't work.
  2. I have 6 projects in my solution. I unbound them one by one. I then unloaded each project one by one. I then reloaded each project one by one. This didn't fix it. I then re-bound each project under File > Source Control > Advanced > Change Source Control. This didn't fix it either.

I have new changes in my solution. Other than downloading the whole solution into a new folder and adding the changes manually, what options do I have to fix this?

P.S. I use Azure DevOps with TFVC for source control.

like image 684
Sam Avatar asked Sep 13 '19 21:09

Sam


1 Answers

I've dealt with these two problems recently with VS 2017. In my case, the binding problem was when moving my local files to a new computer. This is not going to be worthy of the bounty because it's just my work-around but it was too long for a comment.

First I made a copy of my whole solution elsewhere on disk to make sure I don't lose my changes. Then, the only way I could get the bindings to work (frustratingly), was to re-get the solution from source control (had to do Get Specific Version, Latest Version, Overwrite writeable..., & overwrite files even if local version matches...). After that the bindings magically worked (I might have had to restart VS).

Next you need to copy all of your changes back in. Now how you do this depends on your situation. If you know there have not been any changes by other people to the files you have edited, you can just replace the entire files with the copies containing your changes. But if one of those files also has changes in the repo that your changed, local file doesn't contain, when you check in and it does the merge, it's going to think you deleted them.

If the latter case is you, I think the only option is to tediously copy your individual changes over for each file. In both cases, I found BeyondCompare useful for aiding in the comparison and copying, but it looks like you can also make use of Visual Studio's merge tool on two local files. E.G. "%VS110COMNTOOLS%/../IDE/vsdiffmerge.exe" "File1" "File2"

As you mentioned, now that your changes are in, you have to get Visual Studio to recognize them. This one I just had to do due to a branching issue. To do it you can use tf vc /reconcile in the Visual Studio command prompt. E.G.:

tf vc /reconcile /promote /adds /deletes /diff /recursive [itemspec]

I have yet to find official documentation on /reconcile but it seems to go out and identify your local changes, where you can specify the types of changes to look for - /adds, /deletes, /diff. After that you should be able to check in. You might have to refresh the solution in VS if it was already open.

I hope your question gets an answer to what causes Visual Studio to not be able to bind a perfect set of local files back to source control, but hopefully this is also helpful (and applicable to 2019 and Azure) in the mean time.

like image 164
xr280xr Avatar answered Oct 28 '22 20:10

xr280xr