Adding Whole Project to The Source Control - visual-studio

I can add files and folders inside a project into the source control. (Right clicking on files/folders and selecting Source Control -> Add files to Source Control)
But I can not add the whole project into source control, but the older ones are added and a lock sign are beside them. Where is the problem? How can I add the project itself to the source control so I can see the lock sign like other ones.

This may occurs if your solution is not in source control or some bindings conflict when you add that project.
Please open the solution root folder with Windows Explorer to check if the new project exists in the workspace (solution root folder) first. If the project exists, then follow below steps to add the existing project in source control.
Navigate to solution root in Source Control Explorer
Right click in Source Control Explorer and select Add items to
folder
Select the Project folder you have created, then Next
Select items to add or Excluded, then Finish
Check in the changes
Another place to check is source control bindings, simply unbind and rebind the solutions/ the project or root folders in your workspace. Detail step take a look at here: Re-establish TFS source control bindings
Normally, new project will be created in the solution root folder and the files will be added in source control automatically if the solution has already been in source control.
For any newly added project, just pay attention to Enabling Add to Source Control Option for New Project Dialog in Visual Studio

Go to the Team Explorer -> Source Control and manually add the files using the "Add Items to Folder" menu item.

Related

The item is already under source control at selected location

How can I add a Visual Studio solution to the TFS? I created a new project named, for example, PROJECTX and I have solution with the name PROJECTX.sln. I select File > Source Control > Add Solution To Source Control, but immediately I get this error:
I also deleted and recreated the same project in TFS and my solution does not have any .vssscc files, therefore I think it wasn't in TFS before, maybe some other copy... but when I deleted the project in TFS, it should not matter, right? I tried the bind/unbind option, but it seems that I'm missing something important. Also I don't have any pending changes and the TFS project is empty on the TFS server.
If I select the Ignore All option, I cant check in the files, because it tells me it is already checked in.
On my case, I had to correct the binding using the Change Source Control dialog box :
Select solution or project that you want to add to source control
Go to "File" -> "Source Control" -> "Advanced" -> "Change source control" (if you look at Microsoft website, you will see that there is not "Advanced" menu in their example, it may be related to VS version or menu settings).
Click "Bind" on each row.
If a row in underlined in red, it may indicate that the current project is not checked in into TFS, check-in all project before you proceed to the binding.
Microsoft - How to : Bind and Unbind Projects and Solutions
Close the solution .
open the solution file in notepad
Then remove the below section.
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {3CF58AB4-18FA-4F8D-95D4-32DDF27D189R}
SccTeamFoundationServer = https://serverIP/Project
SccLocalPath0 = .
SccProjectUniqueName1 = Ecample\\Example.csproj
SccProjectName1 = Example
SccLocalPath1 = Example
EndGlobalSection
then open the solution once again it should prompt to bind, do the binding properly.
I solved this issue by copying the project folder to the new windows folder outside of local tfs workspace.
I had the same. I first created a new folder in TFS, then in File Manager, copy the whole project w/o .sln file to this folder (TFS already created in file system), back in TFS, clicked on "+" icon to add everything underneath this new folder.
Then checked in for the first time.
Continued working on the project made some changes. I thought it's okay to "Add Solution to TFS", still the same problem, even though removing all .vss files/folders.
Since I know TFS already has a copy, so I "Compare" it with my local version see the difference there.
So I just clicked on "Ignore All" button, Bingo, works.
This is how you need to bind the solution to the server
I followed these steps:
If you're already in Visual Studio with the solution opened, close the solution via: File > Close solution.
In Source Control Explorer window, in "Folder" section (left side of the screen), navigate between your TFS projects, find and open the solution you want.
You'll get a message saying:
The solution you are opening is bound to the source control on the
following Team Foundation Server: your_server_folder.
Would you like to contact this server to try to enable source control integration?
Press Yes and if the connection is correct, you'll see now your solution is bind to source control.

TFS source control - new files not automatically detected as pending changes

As per the tags, I'm using VS2013 and TFS2013.
There are multiple projects in the solution: Model, Presenter, View, etc. All other projects are working as expected in terms of source control operations.
Problems with the Model project:
Adding a new file via Solution Explorer isn't automatically detected as a pending change
Deleting a file isn't detected either
Other source control operations work fine for the Model project, such as:
Get latest version
Edit detection for existing files (including changes to the csproj
file when a new file is added)
Checking in pending changes
The csproj file would show up in pending changes with the newly added file listed in it, but the new file itself isn't showing up, therefore causing build errors on other developers' machines if only the csproj changes are checked in.
The workaround is to find the added file in solution explorer and Add via context menu, this will make it appear as a pending change. But this process should be automatic as per the other projects.
Noticed that there is no .vspscc file for the Model project while other projects have one each.
Any help appreciated. Thanks.
I would unbind and rebind the problem project and try again:
To unbind a solution or project from source control
In Visual Studio, open Solution Explorer and select a solution or
project to unbind.
On the File menu, click Source Control, then Change Source Control.
In the Change Source Control dialog box, click Unbind.
To bind a solution or project to source control
In Visual Studio, open Solution Explorer and select a solution or project to bind.
On the File menu, click Source Control, then Change Source Control.
In the Change Source Control dialog box, click Bind.
Select the database and location to which to bind, and click OK.
Click OK.
You might need to go to Advanced to find the Change Source Control option
https://msdn.microsoft.com/en-us/library/0eh3790h%28v=vs.90%29.aspx
Before unbinding and binding your solution try his:
Go to Source Control Explorer
Click the "Add Items to Folder" (the
one on the left of the red cross)
Select the items you want to Add and follow the instructions on screen
That's all
Click <Detected: x add(s), x delete(s)> : in the source control explorer then select the file to add
For years I've been relying on 'Detected Adds' to add missing files - which was never a sustainable solution but I've just about managed with it.
But now if broke.
I'm actually about to reinstall Windows but in the meantime one of the best ways I've found to get a sense on what's missing (and it's still working even though the detected adds isn't) is the recursive 'Compare' window.
You can add files from here too.
It's a little klunky but it gives me a good sense of security and shows file diffs if you want to see what may have changes.

TFS - Moved files showing 'Add files to Source Control' when already in source control

Should I be worried that TFS is still telling me to ‘Add files to Source Control’ when they already are having moved files from one project to another in the same solution?
To provide some background, I got multiple projects in my solution. I needed to move a complete folder structure and the files from one project to another and sit them in a new directory.
So for example
Moving contents of ‘Website.Assets’ - $/Adam/Website/Website.Assets
To a new folder named ‘Assets’ in another project - $/Adam/Website/Website.App/Assets
I added the new folder ‘Assets’ via source control explorer and then added it into the project via solution explorer.
Having then moved the folders/files from the one project to the other via the move functionality in source control explore, then added to the project and checked in. The project now states there are still files to be added to source control, when there isn’t.
It's only when I right kick on the new parent folder 'Assets' that I see the message 'Add files to Source Control' non of the files that were moved from the other project to this project show this message.
Is this something to even worry about? If so any suggestions on fixing it?

How do I get Visual Studio Team Foundation Server to see I moved code to a different folder?

I moved some code from my c drive to my d drive. When I opened the solution, it told me that:
The solution appears to be under source control, but its binding
information cannot be found. Because it is not possible to recover
this missing information automatically, the projects whose bindings
are missing will be treated as not under source control.
So I tried permanently removing the bindings and downloaded the latest version. Now my changes don't register as pending changes.
I've tried selecting the solution in the Solution Explorer and File => Source Control => Change Source control, but it does not let me bind. Server Name and Server Binding columns have "".
Generally speaking, the location of code on your machine is dependent upon where your workspace is located.
If you move your workspace to the D: drive, then there shouldn't be an issue.
However, if you simply used Explorer to copy the files to the new location, then VS isn't going to be able to maintain the bindings.
From the Workspace Editor you can map the entire tree, solutions or even individual projects to a new location.
First off, put it back and undo the changes.
Then, Go to File | Source Control | Workspaces.
Click on the work space name and then the "Edit..." button.
In the working folders area select the source control folder you want to move and give it a new local folder location.
You will need to edit your Workspaces for TFS Server to know the change that has happened at your local machine. To edit your workspace, in Visual Studio:
ensure you have no pending changes; also copy your source code folder to some location temporarily, just to be safe (you can remove after you are all set)
go to Source Control Explorer
locate the "Workspace:" dropdown
select the item "Workspaces" from the dropdown list (you will get a dialog titled "Manage Workspaces"
if you have multiple Workspaces, select the appropriate one from the list in the dialog
click on "Edit" button (you will get an "Edit Workspace..." dialog)
down below in the dialog, you will see "Working folders" grid
click on appropriate row from the grid and modify the "Local folder" path to set to your new folder location
Sometimes TFS and Visual Studio have issues in getting these workspace changes synchronized. I would always close Visual Studio and re-launch it to get my changes synchronized anytime after I make Workspace related changes.
Hope this helps.
the most crude way here (I don't know if there is any other way)
is to put the folder back to its old location , Check in your changes
then remap the project to the new folder
When you move files/folders to make the moves pending changes you need to use a TFS client to do the moves.
For one or two files the Team Explorer UI is OK, for more the command line is easiest.
See tf.exe rename on MSDN (tf move is an alias for rename). There is also step by step help on using the GUI: Move, Rename, and Delete Version-Controlled Files and Folders.

Add an existing folder to TFS source control

Is there any way I can add an existing folder to source control in TFS? I have created a new folder outside of TFS, just in the file system, and would like to add it to source control, but the only apparent way to do this is the ridiculous workaround of renaming my new folder to a temp name, then creating the new folder in Source Control Explorer, then adding the items from my renamed, original new folder.
Just select the folder after selecting the "Add Items to Folder..." option. You can get to this is from the context menu you get when right clicking on a folder (either the name or the actual folder itself).
The next page of the wizard will present you with lists of included and excluded files. Select the files you want and then hit "Finish".
Then submit the pending changes.
Let me share you a easier way that I just figured out.
(I was having the same trouble, and that is why I found this post.)
Drag the folder you want to add to the solution explorer and drop at the place you want to add.
Ta Ta ! It is done.
Mine is VS2010.
Before dragging and dropping or selecting Add Items To Folder, you must map the parent TFS folder to your local drive.
That is, if you want to add a C:\Stuff\HelloWorld directory to the /Top/Projects folder in TFS, you must first map /Top/Projects to C:\Stuff and then add HelloWorld.

Resources