14

I have a large solution in Visual Studio that is under TFS Source Control but I've noticed one of the projects (c#) doesn't have a padlock icon next to it in Solution Explorer.

The project and it's files are all under source control, I can look at the history and do other tasks. None of the files have the padlock, but strangely the properties folder does.

What is the cause, what does it break and how do I fix it.

Stephen Turner
  • 7,125
  • 4
  • 51
  • 68

6 Answers6

35

All that is wrong is that the Project file does not have the correct binding to TFS. There is a section missing in the .csproj file that should look something like this:

<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>

Where SAK (probably) stands for Solution Already Knows.

As far as I know it only affects the display of the Source Control status in the Solution Explorer as noted you can already perform other source control tasks on the project. It's not much but worth fixing as it's a good visual check that everything is being controlled.

To fix it highlight the project in the Solution Explorer, then go to File > Source Control > Advanced... > Change Source Control... Select the project in question in that list (it'll probably look fine and valid), click Unbind, ok the warning then click Bind (the same toolbar button relabelled) Ok that window, and checkout all the files it suggests. This will make the necessary changes and the padlocks should appear. Review and check the changes to keep them.

Stephen Turner
  • 7,125
  • 4
  • 51
  • 68
  • For VS2015 I also went to "Change Source Control" and saw all projects had stats "Invalid." I unbound one project then clicked OK and got a warning that there were still invalid bindings. In that window there was a button that allowed me to fix all unbound projects rather than going one by one. – Duderino9000 Jun 09 '16 at 15:57
  • For me, binding (re) some of those projects without padlock forced me to check out those projects. As there were no changes to csproj files on my end, I undid the check out after checking them out. Now all projects in solution seem to be under the source control (pad locked). – DiligentKarma Oct 10 '17 at 23:32
  • Perfectly solves the problem, I just unloaded the project and added scc tags mentioned in answer and icons appeared back :) – Dreamweaver Jan 16 '18 at 07:08
  • This basically worked for me but all I had to do was highlight the project in Solution Explorer, then go to File > Source Control > Advanced > **Refresh Status**. – Kidquick Jun 27 '19 at 21:05
10

For me the icon was missing as well.... but ALSO, the actual .csproj was not in showing up in the TFS Source Control Explorer view. (Meaning the .csproj was not actually being source controlled.... even though all the project's directories and files WERE being source controlled.)

The solution for me was to have the folder open in TFS Source Control Explorer in Visual Studio 2015.... and also have a Windows File Explorer window open where I could see the .csproj file on my local computer..... And then simply drag and drop the file from Windows File Explorer to Visual Studio's TFS Source Control Explorer window.

Then I immediately saw the Project had the plus icon (and was visible under the pending changes list as well). I performed a check in and then the lock icon now appears on my project! :-D

Jason Parker
  • 4,960
  • 4
  • 41
  • 52
3

At "Solution Explorer", select the solution file, then go to "File > Source Control > Advance > Change Source Control". Make sure "Server Binding" is set, and "Connected" are ticked. Else, highlight those project and click on "Bind" on the top.

Should there be any binding error, probably the project was renamed when the binding wasn't there. Open the "Source Code Explorer" and drag the folders in, Visual Studio will automatically take care of the rest.

TPG
  • 2,811
  • 1
  • 31
  • 52
2

Webturner has the correct solution. But in addition to this I had to manually add the project file to TFS from file system (right click on the project file -> Team Foundation Server -> Add). Then do unbind/bind in VS as Webturner suggests. For me this was all caused by a previous rename of the project file.

HakonIngvaldsen
  • 354
  • 2
  • 12
0

When the project file (.csproj) is not in the source control then it would not have a padlock next to the project.

Dennis
  • 1
0

I'm guessing there are multiple things possibly going on here.

The latest incarnation of this for me was solved by right-clicking on the project, source control, go online.

BitsAndBytes
  • 815
  • 1
  • 9
  • 13