Monday, February 6, 2012

Finding your way around TFS with Visual Studio 2010

So, one of my best friends has been using TFS in his work place for 6 months now, and we've also been developing some software together.  We've been using Subversion (SVN), with Ankh SVN, integrated into Visual Studio.  When the opportunity came up to try TFS2011 (with tfspreview) I decided to migrate us over. We'd been running with it for a couple fo weeks, but it was obvious I needed to get my mate up to speed with TFS.  I've been using it for over 4 years and started with TFS2005.  I've been happily using TFS2010 for a while.  So I went through and scribbled down the basics of some of the common features of TFS and sent them over in an email.
Again, its a lot of info that is probably best shared.


First thing you need to know, TFS isn't just a source control repository, but that's all we've been using it as so far.  The example below is showing two separate MVC3 projects, but they're not the point of this post, so I won't talk about them here.

Solution Explorer:
Solution Explorer
You know what this is, its the Solution Explorer, the clue is in the name.   However, it's worth mentioning the little symbols next to each file:

- the padlock means the file is checked in to TFS.  Nobody else has it checked out.
- the little person icon means its in TFS, but someone else has the file checked out.

We can have different types of check out.  We can lock the file exclusively, which means nobody else can check it out.  Or, as we have it set up, we allow parallel checkouts.  When you come to check in, if you're the first, it's straight forward, its a check in.  If you're following a checkin, you'll have to merge the file.  It might do it automatically, or you might have to manually merge it, in the merge tool. 
Why does it sometimes make you merge it and why sometimes can it automatically do it itself?
Lets say I make a change at the bottom of the file and you make a change at the top.  It's easy for the system to merge this, it'll do it itself.  But, if the changes are on consecutive lines, or even on the same line, then it'll ask you to merge the conflict yourself. 

Some say it's good practice to 'get latest' before checking in.  I'm not so sure.  But if it ever asks you to merge a file, lets share desktop and resolve it between us.

How do I find out who's got a file checked out?
If someone has a file checked out, you'll see the little person icon next to the file.  I'll show you the source control explorer later.  All you need to do is navigate to the file in the Source Controller and it'll show you who has the file checked out.
How do I add a new file?
If it's a piece of code, go to the directory you want to add it to, right click...

Add a new file to TFS

...and add your chosen type.  I chose to add a class, and call it bollocks...

New File Added to TFS
A new + symbol, that means its just been added to the project, but not yet checked in to TFS.

But, I've got an image I want to add!!
That's fine, just add an existing item...

Add an existing file to TFS
And your new file is in the project:



Existing file added to TFS

Next up, Pending Changes:

Pending Changes
Anything that you've added, updated, deleted, moved, etc will end up in your pending changes window.  I've got mine to show up at the bottom of the screen:

Pending Changes
So, my project file (MvcExample.csproj) file has been ammended because I've added two new files.  Then you can see that it's showing my two newly added files.   newImage.png is also marked as locked - this is because you can't have a parallel checkout on an image - how on earth would you merge it?

I'm not going to check these in, I don't really want them in my solution.  Instead, I'm going to highlight all 4 files and undo...

Undo Pending Changes
Next up, Team Explorer:

Team Explorer
Team Explorer
If we had multiple projects, we'd see more than just 'EntraNet', but that's our project.  Within there we have three items.
  • Work Items
  • Builds
  • Source Control
Work Items
We have a number of types of Work Item, and you can add one by right clicking and selecting New Workitem...

New Workitem

What are they all for? 

Bug
Ok, register a bug if somethings broken.  If you're getting an error, or its just not working, raise a bug.
Bug
Its fairly self explanatory.  But please do fill out the Repro Steps as though I'm an idiot.  I, or anyone, should be able to read the steps and reproduce the bug.  If I can't reproduce it, its not an bug.

Code Reviews, request and response
We use these extensively at work, but lets skip these 2, we're not using them.  Essentially, we can put in some check in rules, so that we can't check in without the changeset being reviewed and approved.
Feedback - Request and Response
I've never used these before.  These are new to TFS 2011.  Do we want to make use of this?  More details here:  http://blogs.msdn.com/b/visualstudioalm/archive/2011/09/20/feedback-on-working-software.aspx I think it probably makes sense.  When I think something has got to a state where it's usable, I can initiate a feedback request - and we do it via TFS, rather than email - so its all recorded.

Issue
Another new workitem type.  If there's something missing, or you don't like the way something works, raise it as an issue.  All comments get recorded in TFS.



Issue

They look fairly straight forward.
Shared Steps.
I have no idea what these are, lets ignore these.
User Story
A Story is a high level requirement. Something like:

As an Administrator, I want to be able to administer countries, so that I can keep my country list up to date


Task
Tasks hang off stories.  These are the physical actions that people need to take to complete the story.

Builds
Lets forget builds for now.  That for when we want to define a build, that builds our project, via a series of scripts, on the server (or another configured build server)
Source Control
This opens the source control explorer.

Here we can explorer the source, directly within TFS. We can navigate our way to a solution, and open directly from TFS:

Open a solution from Source Control Explorer
Double click the '.sln' file and it'll open the entire solution (in this case with 2 projects); A solution consists of one or more projects. 

You can get the history of of any item in source control, by right clicking and 'View History'

View History in Source Control Explorer
So, here I'm wanting to view the history of the whole of the solution.  It shows me all changesets in the history of the solutiuon.  You can check the history at Solution, Project Directory or Fiile level.  The history looks like this:


It's not showing the individual changes to files, its showing you each Changeset.  A changeset is the set of files grouped at a single checkin.  If you check in a single file on its own, you create a changeset with a siingle file, if you check in 100 files together, you've created a changeset with 100 files.

You can see the contents of a Changeset...

View Changeset

And you can see the specific changes in the file by drilling down even further...
Compare with Previous Version

Then that shows how it was, and how it is now...



View Differences

No comments:

Post a Comment