简体   繁体   中英

TFS Binding Invalid After Upgrading Project From VS2015 to VS2017

I began working on an .Net Core solution in VS 2015, which contains an ASP.Net Core project and a couple of .Net Core class libraries. The solution was under TFS source control.

I wanted to include some unit tests. Since .Net Core unit test project templates are not included with VS 2015, I decided to install VS 2017 and upgrade the solution. After upgrading, I was able to add a unit test project and everything compiles and runs normally.

When I first opened the solution after upgrading, though, I initially got an error about the solution being treated as though it was not under source control. Based on Google searches, I went into File -> Source Control -> Advanced -> Change Source Control and clicked "Bind" on each project. The three old projects link right up and show up as "Valid", while the solution file and the new unit test project show up as "Invalid". Unbinding, unloading, reloading, and rebinding the invalid project did not help. I can force the project to bind even though it is invalid (against Visual Studio's warnings), and after some tinkering, I can get the solution to check in, but when I get latest on another machine, the three original projects say "Not Available" and the unit test project is not visible.

Other symptoms: project.json is not found when I try to check in (I have to "undo" or "exclude" to check the solution in) and regardless of what I try, the invalid unit test project's folder shows up in the root folder of the directory tree (at the same level as "src" and "Backup") while the valid projects are in the "src" directory. I am inferring this is because the new solution types allow an .xproj file, while the old solutions required project.json, but I don't know what to do about it...

Any ideas on how to relink this to source control would be appreciated! I did not upgrade TFS server when I upgraded VS, but I don't directly have access to it, so hopefully this is not a requirement...

To fix the invalid binding in VS, you could try to follow below steps:

  1. Click the “invalid” project in Solution Explorer.
  2. Open “ File | Source Control | Change Source Control
  3. Unbind the invalid project.
  4. In Solution Explorer, Unload the project.
  5. In Solution Explorer, Reload the project.

Also clear TFS and VS cache , delete the old workspace, create a new one, get all projects you need from TFS source control. Everything should be back on track.

Sledgehammer approach not normally needed, just Delete the contents from the following folder

C:\Users\<<Your Alias>>\AppData\Local\Microsoft\Team Foundation

Do not delete the rest unless necessary, fix the cause not the symptom.

My issue was that the project name had a period '.' in it. Removed it and the change source control Bind was Valid.

I tried all the solution above and none of them worked for me.

But I found a way to force add project. In Visual Studio :

  • Go to team explorer
  • Click on Home
  • Click on Source Control Explorer
  • Select the directory and click on "Add Items to Folder" (the icon is a file with a little green + in the top left corner)
  • Add your project files

... problem solved

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM