.NET Zone is brought to you in partnership with:

I'm an independent consultant working in Italy with more than 8 years of experience in designing and developing application for .NET framework, both in windows and Web environments. I'm particularly involved in Continuous Integration strategies, and designing infrastructure of applications, since I'm a lover of pattern and Application Lifecycle Management. I'm a great fan of Communities and I'm a co-founder of DotNetMarche, an Italian community focused on .NET development and I love blogging about technology. Ricci is a DZone MVB and is not an employee of DZone and has posted 42 posts at DZone. View Full User Profile

How to Add an Existing Project to TFS

02.09.2012
| 40643 views |
  • submit to reddit

This is a super basic and easy question, but I found quite often people asking me how to add an existing project to a TFS Team Project. It turns out that there are more than one way of doing this, but I usually suggests this simple path that is quite simple and is understandable from people that comes from the subversion world.

First of all be sure that you have a valid workspace in your computer that maps the folder in the Team Project where you want to put your existing project and issue a GetLatest. If the team project is new you can simply create a workspace going to menu File –> source control –> Workspaces, press add and create a workspace that maps the source to a folder on your pc.

SNAGHTML2b6825

Figure 1: Creating a workspace that maps the whole folder of the source control.

Now simply go to the local folder and move the existing solution from the original location to the mapped folder, then go to the Team Explorer –> Source control and manually add all the files to Tfs Source Control. In Figure2 I represented the process to accomplish this task, first of all select Source Control, press the add button then Visual Studio presents you all the files that are in your local folder but are not present in the source control (they are the candidate to be added to the source control).

image

Figure 2: Adding existing file to source control

Now you are presented with a list of all the files that will be added to TFS source control, as seen in figure 3

image

Figure 3: List of files that gets added to the source control.

As you can see some of the files are excluded (22 in Figure 3), this happens because Visual Studio already knows that certain types of file should be excluded from source control, like all the Bin and Debug folders and all *.dll files. If you have some lib folder where you store third party library, you can go to the Excluded Items tab in Figure 3 to add manually all the excluded files you want to be added to the source control. Since this window is usually cluttered with all the bin and obj directory, I found simpler to:

  1. 1) in a first pass add all the file suggested by Visual Studio
  2. 2) browse to lib directory (or whatever folder contains third party library) and add explicitly all the files in the directory.

Now all files were in Pending-add, this means that they will be sent to the source control with a  check-in, but before the check-in phase you should open solution file from the source control explorer windows. After the solution is opened Visual studio should tell you that this solution is in a source control monitored folder, but source control is not enabled

SNAGHTML389943

This basically means that, source files are correctly linked to the source control system, but the Visual Studio integration is not enabled, you can simply press Yes and let Visual Studio actually do binding between projects and source control.

If the binding does not happens automatically you will get the windows of Figure 4, (you can always open this windows with the menu File –> Source Control –> Change Source control. In this window you can simply select one project at a time and press the Bind button to perform the bind, until all the project files are in Connected Status.

image

Figure 4: Binding windows where you can bind solution and projects file to TFS

Now you can check-in everything and usually you should create another workspace or ask to another member of the team to do a get-latest of the just-inserted solution, to verify that all the needed files were correctly added to the source control.

Gian Maria.

Source: http://www.codewrecks.com/blog/index.php/2012/01/27/add-existing-project-to-tfs

Published at DZone with permission of Ricci Gian Maria, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Imdadyano Yano replied on Tue, 2012/03/13 - 6:17am

Hello,

Nice article. I really appreciate this. This can be very helpful to the developers while creating the application architecture and adding it to the TFS. I think you have shown how to bind the existing project to TFS. Am I right?But I really appreciate your efforts. You canalso follow the links below for thius one

 http://social.msdn.microsoft.com/Forums/is/vstsstart/thread/abe987e2-eeb6-4c5b-a42c-0f8636c1750a

http://larrywatanabe.blogspot.com/2010/07/adding-existing-project-to-team.html

Thanks once again

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.