No padlock icon for some projects in a source cont

2019-03-27 11:26发布

问题:

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.

回答1:

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.



回答2:

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



回答3:

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.



回答4:

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



回答5:

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.