Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this movie, I will show you how to connect to a Team Foundation Server repository, and work with the source control tools inside Visual Studio. A word of caution: I've already set up the connection to TFS in an earlier movie in this chapter, so if you need a refresher on how to create a connection, you can watch the Setup movie. I'm inside Visual Studio, and I am going to show you how to open a project from source control. I am going to go to File > Source Control, and then Open from Source Control. I already have our project set up on CodePlex.
This is the sample project I created for this class. I am going to drill down into the folders on the server by double-clicking. At this point, I've reached the solution files on the server. Notice that's in a folder called TruffleSoupMain. I am going to select the solution file, and then I am going to go down here and map to a Local Path. So I am going to type in this folder that I created earlier this week, called localSourceFiles, and then I'm going to create another folder called TruffleSoup. Then I am going to click on OK.
We just connected to the server. It's downloading the files to my computer. Now if I right-click on this solution and choose Open Folder in Windows Explorer, you'll see that inside my localSourceFiles folder is the TruffleSoup, and then I've downloaded this Readme.txt, this solution file. If I look in here, you'll see a number of files in here. Notice there are several files that end with this SCC extension. Those are used by the source control engine.
There is another one up here: TruffleSoupMain.vssscc. Hard to say, but that's the name of the extension. I am going to return back to Visual Studio and show you the Source Control. If you can see, there is a little padlock next to each of the icons in here. That means it is under source control, and I don't have an editable copy yet of that file. So if I go over here to this main window, double-click on it--we need to unpin this for a while, this Pending Changes down at the bottom of the screen-- here is the designer surface for this WPF application.
If I go over to the Toolbox, and drag another Button out here, watch what happens to the XAML file over here. There is a red check mark over it, and when I hover over it, it says, checked-out to me. Now if other people check out files, I can get notification on icons here that when I hover over, it'll say it's checked-out to someone else. So that way, I know I can't check out that file. This is what's called a silent checkout. You can change whether it's a silent checkout or whether it prompts you by going to Tools > Options, and then choosing Source Control, and then Environment.
Here's what happens: checked in items. If they're checked in, and I am editing it, it'll check it out automatically. If I'd rather be prompted, I can choose this Prompt for check out. I'll close this. Now, I am going to make my changes. Make this button the same size as the other one, and now I'm ready to check in. So what I do is I go over here, and I say, I have a pending check in here. I want to check this in. It asks me if I want to change my solution file. I say Yes.
Then I'm prompted to check in my source files. Here is where I make my comment. There are also some affiliated items you can see over here: there is Check-in Notes, there is something called the Work Items, and there is Source Files. Now, work items are part of Team Foundation Server. They're like notes of what needs to be done. They can be bug tracking items. I don't have them set up on CodePlex, so I can't add a work item. I am ready to check this code in, so I'll click on Check In.
Now, the other developers can check out this file and start working on it. If I ever want to see the history of what I've been doing, I can right-click here and choose View History. This shows that there has been several change sets on this file. I can see the timestamps on here. So I can see I was working on these last night. I can close this window. Another thing you can do is you can right-click and choose this Annotate item. What this does is it shows you your source code, and then along the edge it shows you where the changes have occurred.
So something got changed up here on change set 1014. This is the latest change set, 1193. This is where I added that second button. So I can see that this is where I changed it. Now, in a real project when you're working with multiple developers, you'll be able to see each person's information over here and which sections they've been working on and what they have changed, which is really handy when you don't understand a piece of code and you need to know who wrote that section. You can go look this up and then go, talk to them and say, "What were you doing here? I don't understand what this code is doing at the moment." So I'll close the annotated version of that.
I am going to make two changes. I am going to double-click on this to write some code, like that. I'm thinking I want to check this in--let me save this-- but I'm not sure what is currently saved in the database. I want to know what the differences are between what I currently have on my machine and what's checked into source control.
So what I can do is right-click on this, and choose Compare, and I'll click on OK. It brings up a Difference tool, and it shows me the two files. And I can obviously see that I've added four or five lines of code here on the local copy. See, it local up here at the top? Here is the server. Here is the timestamp of when this was last saved in the server. Here is the timestamp on the current file when I last saved it locally. Now naturally, I can also edit these files.
I can copy pieces of data back and forth between these two sites. I'm happy with that change. I am ready to check it in, so I'll choose Check In again, and we'll check that in one more time. There is another window you should be aware of. It's available in the View menu, under Other Windows, right here Source Control Explorer.
This is another way of looking at your source control engine. This shows my server and my TruffleSoup sub-item, and then I can click on this and see all of the files as they are on the server. I can do some of the same operations I was doing over here. I can right-click on this and choose Check Out for Edit. I do want to point out that this is a binary file. These are text files. These are binary files, this sample document. So Team Foundation Server creates those slightly differently.
If I attempt to edit this, if I double- click on the SampleDocument.docx, it'll load it into Word 2010, but because it's a binary file, it doesn't automatically check it out. I have to go in and specifically check it out: Check Out for Edit. Now, I can make the changes in the Word doc. Save. Now, this is a common error.
The trouble stems from the fact that the Sample Document is considered a binary file by TFS, and it doesn't automatically check those out when you open them. All you need to do is close this document, and check out from Source Control. Now, it's checked out. Now, we double-click on it to open it, and it will no longer be Read Only. Save. Then I can check it back in.
I can't imagine working on a project without source control. I've used Team Foundation Server on many projects, and it just keeps getting better. Don't forget that Visual Studio also supports other source control servers. I've also worked on several projects that use the subversion server. There are several Visual Studio extensions that allow you to perform the same source control task against the subversion system. Regardless of which one you choose, Visual Studio can bind to the repository.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98693 Viewers
61 Video lessons · 86019 Viewers
71 Video lessons · 69865 Viewers
56 Video lessons · 102148 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.