Archive for the 'Technology' Category

Getting Git Commits with the VSO REST API

(Guest post by Drew Robson – our SSW TimePRO product lead)

​​​​​​​​With Visual Studio Online now supporting Git, ​​​​more developers are changing their source control repositories. What happens if an application you developed relies on the TFS Client Object Model to get information out of source control (e.g. changeset comments) and the developers start using Git?​

That’s where the new Visual Studio Online REST APIs come in. You can get a list of commits from your VSO Git repository with only a HTTP request.​ Let’s look at how to do this with C# and Visual Studio 2013. The below example gets all the commits for a particular user.

(This is based on Get started with the REST APIs and VSO Integration Reference)

You will need a method to execute the HTTP GET request.

private async Task<string> Get(HttpClient client, string url)
    var result = string.Empty;

    using (HttpResponseMessage response = client.GetAsync(url).Result)
        result = await response.Content.ReadAsStringAsync();

    return result;

And a method to set up the authentication and urls.

public async Task<IEnumerable<Commit>> GetGitCommits(string username, DateTime from, DateTime to)
    var result = new List<Commit>();

    using (var client = new HttpClient())
        if(_settings.AuthType == AuthType.Basic.ToString())
            var version = "api-version=1.0-preview.1";

            // Set up auth
            var parameters = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", _settings.Username, _settings.Password)));
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", parameters);

            // Get Git repositories
            var url = string.Format("{0}/{1}/_apis/git/repositories?",
            var response = await Get(client, url + version);
            var repositories = JsonConvert.DeserializeObject<RepositoryCollection<Repository>>(response);

            // Get Git commits
            foreach (var r in repositories.Value)
                url = string.Format("{0}/{1}/_apis/git/{2}/repositories/{2}/commits?committer={3}&fromdate={4}&todate={5}&",

                response = await Get(client, url + version);
                var collection = JsonConvert.DeserializeObject<CommitCollection<Commit>>(response);
                if (collection != null
                    && collection.count > 0)

    return result;

What about the classes RepositoryCollection, Repository, CommitCollection and Commit? These are the class representations of the JSON responses. See the SSW Rule Do you know how to easily get classes from a JSON response? to generate them.

Release Management for the Enterprise (with videos!)

Team Foundation Server has been a great tool for managing your development projects for some time. But while it’s been a great source control and work item management tool, it’s always lacked a bit in terms of managing the deployment cycle of your application.

Too often, deployments rely on Frank from the Infrastructure team studiously following a word document to make sure every step has been checked off. It’s error-prone to say the least.

There are two great tools that are changing that. Both give you highly repeatable and automated deployments, reducing the risk of an outage.

The first is a new tool from Microsoft called Release Management for Visual Studio 2013. Yes, that’s a long name. The product has been around for a while under a different name (InRelease), but was recently acquired by Microsoft to improve this area of their offering. It’s closely-integrated with Team Foundation Server and gives you the ability to control your releases and know exactly who did what. It’s great for enterprises.

If you’re lucky enough to be at Tech Ed New Zealand this year, I’ll be speaking about it on Wednesday afternoon. I’m yet to hear about Tech Ed Australia, but I’ll let you know when I know :).

The other tool is one I’ve been using for a while called Octopus Deploy. It gives many of the same benefits as Release Management, but isn’t as closely tied to the Microsoft infrastructure. That means you can use it to deploy nearly anything from nearly any source (not just TFS).

I’ve spoken about Octopus Deploy a couple of times in the past few months, so rather than go through the features on this blog, I’ll just show you the videos.

For a quick introduction, watch my conversation with another SSW developer and MVP, Danijel Malik, about Octopus Deploy:

I also presented at DDD Melbourne recently about Octopus Deploy, and why it’s a great tool to stop you “deploying like an idiot”:

I hope you enjoy the videos, and I’m looking forward to talking about the other great tool, Release Management, at Tech Ed NZ.

TFS Maintenance – cleaning up after yourself

It’s really important to have a TFS Master as part of your team.  As the TFS Master at SSW (amongst other things), I’m constantly looking out for best practices, improvements we can make, and problems we can avoid. In particular, we like to keep our Team Foundation Server nice and clean, making sure the devs have no abandoned changes or workspaces.

Periodically, I’ll send out an email to anyone who has files they haven’t checked in for a while as per our “Do you have a report to see who has not checked in?” rule. What I often hear back is that the files have been checked out in a workspace that no longer exists. In other words the files were edited, not checked in, then the computer was rebuilt or replaced.

So what can you do?

The best option is to remove any workspaces you no longer have access to. There are two ways to do this:

  1. Use the awesome Team Foundation Sidekicks product
  2. Use the Workspaces tool in Visual Studio


Option 1 – Using Team Foundation Sidekicks

  1. Download Team Foundation Sidekicks 5.0
  2. Connect to your Team Foundation Server
  3. Use the Workspaces Sidekick to find and remove any workspaces you no longer use

Using Team Foundation Sidekicks to remove Workspaces

Using Team Foundation Sidekicks to remove Workspaces


Option 2 – Using the Workspaces tool in Visual Studio

  1. In Visual Studio, go to File | Source Control | Advanced | Workspaces…
  2. Check the Show remote workspaces checkbox to see workspaces on every computer
  3. Select and click Remove for the workspaces you no longer use

Opening TFS Workspaces in Visual Studio

Opening TFS Workspaces in Visual Studio

The Workspaces Dialog in Visual Studio

The Workspaces Dialog in Visual Studio


Clearing out these abandoned workspaces will let the TFS server know you aren’t using those workspaces any more. Best of all, your TFS Master will be less likely to send out angry emails!

I’ve been awarded a Microsoft MVP in Visual Studio ALM!

Microsoft MVP logoA few days ago I received an email from Microsoft informing me that I’d been awarded an MVP for Visual Studio ALM.

While my participation in the dev community has been purely for the enjoyment and love of what I do, this has been a career goal of mine and something I’ve been working towards for a few years.  I’m super excited and humbled to have been awarded alongside many of the best guys and girls in the field.

For those unfamiliar with what this award means, the best information can be found at, but here’s a quick quote from the site:

The Microsoft Most Valuable Professional (MVP) Award is our way of saying thank you to exceptional, independent community leaders who share their passion, technical expertise, and real-world knowledge of Microsoft products with others. … Today, there are more than 4,000 MVPs worldwide. They represent more than 90 countries, speak over 40 languages, answer more than 10 million questions a year, and are awarded in almost 90 Microsoft technologies—reflecting the breadth of our products and our global communities.

Thanks must go to the awesome guys and girls I work with at SSW for their support, as well as to the many enthusiastic developers I interact with as an organiser of the Brisbane .Net User Group and DDD Brisbane.

Here’s to a great 2014!


How to change a Work Item’s type in Team Foundation Server

One of the most frequent questions I get asked when training a new team in TFS is how to change a Work Item’s type.  If the team is coming from Jira, I can almost guarantee I’ll get asked that question.

While you can’t change the type of an existing Work Item with Team Foundation Server 2012 and 2013, there’s a simple workaround that achieves the same result.

How to change a Work Item’s type

First, open the Work Item in Team Web Access and click this button: Copy Work Item Button

The Copy Work Item button in Team Web Access

The Copy Work Item button in Team Web Access

In the dialog, choose the Work Item type you want to change it to, and click OK.

Choose the Work Item Type

Choose the Work Item Type

Finally, go back to the original Work Item and change its state to an appropriate “closed” state. If you really want to remove all traces of the original work item, you can use the command line “witadmin destroywi” tool. I don’t recommend this!

You can perform the same tasks from within Visual Studio by right-clicking on the work item and choosing “Create Copy of Work Item”.

Visual Studio - Copy Work Item

Visual Studio – Copy Work Item

It’s a deep copy

If you look at the new Work Item, you’ll see that all of the detail and links have been copied across where there’s a corresponding field in the new type.

All related Work Items are linked, and even links to Changesets that applied to the original Work Item are copied.

Deep Copy of Work Items

Deep Copy of Work Items

This tip can be really useful for Product Owners who like to create “bugs” that don’t fit your bug definition and are really new requirements.

So there you have it, a way of “changing” the type of a Work Item that should please those Jira converts!

The new, shiny goodies in Visual Studio and TFS

I recently spent a couple of weeks speaking at Tech Ed Australia and Tech Ed New Zealand with Adam Cogan.  You can see recordings of the Tech Ed Australia sessions or the Tech Ed New Zealand ones on Channel 9 if you want the full presentation.

In this post, I wanted to specifically point out a few of my favourite Visual Studio ALM features from our sessions.

Visual Studio IDE – Peek

When I’m reading code, I’m used to jumping around between files to find definitions and usages using key combinations like F12, Ctrl+F12Shift+F12, Ctrl+-, and Ctrl+Shift+-.  Peek adds yet another key combination – Alt+F12 – to the mix, and it’s an awesome addition.

When your cursor is in the right place, just hit Alt+F12, and the definition will expand below.  Even better, you can edit it inline!  Just hit Esc when you don’t want to see it any more.

Visual Studio 2013 - Peek

Visual Studio 2013 – Peek

This small thing has already saved me so much time while coding.

Visual Studio IDE – Code Lens

When you open a project in Visual Studio 2013, you’ll notice a couple of additional bits of text above things like class methods and properties.  These code lens helpers let you see at a glance, some really important information about the method or member below.

You’ll see:

  • References
  • The number of tests that touch this code
  • TFS information about this code including recent changes and associated work items

Hovering over these bits of text (or using shortcut keys Alt+1, Alt+2, etc.) expands this information and gives you the opportunity to run tests or navigate to code, TFS changesets, or work items.

Visual Studio 2013 - Code Lens

Visual Studio 2013 – Code Lens

This is incredibly powerful.  You can see immediately how this code is being used and what has happened to it. without needing to leave your code.

Team Foundation Service – Test Case Grid View

This feature is brand new (only a couple of days old) so we didn’t get a chance to announce it at Tech Ed Australia.  A demo will be in the Tech Ed New Zealand video when it’s live.

There’s a new option in the Test hub in Web Access where you can change the view of your Test Cases to “Grid”.  Just click on the View item on the right.

Team Foundation Service - Test Grid View

Team Foundation Service – Test Grid View

Team Foundation Service - Test Grid View

Team Foundation Service – Test Grid View

What’s amazing about this view is that you can paste straight from Excel!  If that doesn’t make your testers happy, nothing will!

Team Foundation Service – Team Room

The addition of a team room to TFS adds some awesome collaboration features to Web Access.  It’s particularly useful for remote teams (which I work in a lot).  Rather than just a chat room though, it can feed you information about your project.  You can see build completions, changes to code, and updates to Work Items.

Team Foundation Service - Team Room

Team Foundation Service – Team Room

The faster release cadence of the ALM team has meant much faster additions to Team Foundation Service. If I can suggest one thing, it’s to move your ALM process onto the cloud because there’s much more to come!

There are many more great features in VS and TFS 2013.  I encourage you to take a look.

VS 2013 – Packed Rooms at Tech Ed Australia and New Zealand

Developers are very excited to get their hands on Visual Studio 2013!

I’ve spent the last couple of weeks speaking at Tech Ed Australia and Tech Ed New Zealand with Adam Cogan.  We’ve been demonstrating the awesome new features in Visual Studio 2013, as well Team Foundation Server and Microsoft Test Manager.

Watch the recordings of the Tech Ed Australia sessions on Channel 9.

Note: At time of writing, one of the videos is unavailable. It should be online for viewing by midday 13th September.

Update: Both videos are available now

Channel 9 - Tech Ed Australia - My Sessions

Channel 9 – Tech Ed Australia – My Sessions

The rooms at Tech Ed Australia were packed!  About 450 developers came to see the two sessions showing just how popular the Visual Studio ALM stack is.

In my next post, I’ll go through some of the highlights of the two sessions.

Glimpse Heads Up Display released

Today, Anthony van der Hoorn and Nik Molnar announced the release of a new version of Glimpse with a big new feature – the Heads Up Display.

I’ve been lucky enough to see this new feature grow into its current form and in my opinion, it takes this tool from the “very useful” category into the realm of “must have”.

SSW has been recommending Glimpse for some time.  With the addition of this feature, we now recommend you use it all the time!

The New HUD

Assuming you’re familiar with the previous version of Glimpse, you’ll know that once it’s set up and turned on, you see a small icon on the bottom-right of your screen (Old Glimpse Icon).  Clicking it will expand a big devtools-esque view of what’s happening on your server.  Incredibly useful.

I often keep Glimpse running while I’m in development, and whenever I want to know about what route was hit or how many SQL queries were executed for this page, I’ll click the icon and have a look.

The point is, I have to look.  Glimpse required the developer to actively investigate.  The new Heads Up Display changes the game – now I don’t have to be looking for the cause of a problem, the information is there all the time.  You now have a very powerful and proactive tool at your disposal.

Example Time!

I frequently use Glimpse to verify that a page I’m looking at doesn’t suffer from the dreaded N+1 Selects problem you can get with a lot of ORM tools.  The SQL tab (see Glimpse.Ado and Glimpse.EF) let me see what queries are being run against my SQL server.  If I see a lot, there’s likely to be a problem.

With the new Glimpse HUD, that information is always there whether I’m actively looking for it or not.  While testing one of the pre-release versions of the HUD, I noticed a page on a project I was working on that resulted in 74 SQL queries.  Had I been using the old version of Glimpse, I may not have noticed (I wasn’t working on that page)!

Here’s what I saw (minus the issue):

New Glimpse HUD

Above, you can see the number of Database queries and the time taken for those queries.  In my case, I noticed this number was a really high.  To  investigate further, I can hover over the “Host” section to get some more info.

New Glimpse Expanded

In this example, we can see that not only were there three queries, we actually have three connections.  In my case, the 74 queries were shared over maybe a dozen connections.  Something was going wrong here.  You’ll note we can see lots more information about what’s going on in terms of Controller Actions and Views as well.

As with previous versions, we can click the (new) Glimpse logo to expand Glimpse into its full view, showing us the actual queries that were run against the database.  The UI here has been updated as well and is very clean and “metro-y”.  This is where I could see all the repeated queries that were running against my SQL Server.

New Glimpse Full View

Without the HUD, I probably wouldn’t have noticed there was a problem until much later.  Because the HUD gives me this info in a relatively subtle way, I caught this issue quite quickly.


Glimpse now has three modes of delivering you data instead of just the one, and the HUD is the big game-changer here.

First, you get a Heads Up Display (HUD) that I’d strongly recommend you keep open at all times while developing.  It lets you monitor the performance of your application without getting in your way.  More importantly, it’s likely to show you issues preemptively rather than waiting for you to investigate.

If you hover over one of the HUD sections, it expands to give you even more info – this lets you investigate a bit further while still staying out of your way for the most part.

Finally, the full view of Glimpse gives you the UI you’re probably used to if you really want to dig deep.

Get it now!

The new version of Glimpse is live on Nuget, but if you want to read more about the new release, head to or the blog post on the Glimpse Blog.

Getting the Glimpse SQL tab working with Linq to SQL

I’m currently working on an ASP.NET MVC project that’s using Linq to SQL for data access.

As usual, one of my first contributions was adding Glimpse (including Glimpse.MVC4 and Glimpse.Ado), initially as an easy way to confirm my suspicions of the dreaded N+1 problem.

Unfortunately, when I ran it, the SQL tab in Glimpse gave me nothing – Glimpse wasn’t tapping into my data connection.  The issue is Glimpse attaches itself by providing its own GlimpseDbProviderFactory which wraps the standard ones.  This lets it collect information about how you’re using your data connections. Our Linq to SQL implementation wasn’t using this factory so I had to do the work myself.

Here’s how I fixed this issue.  Even if you’re not using Linq to SQL, the solution is fairly generic, so you might find it’ll help you as well.

First, I found the generated Data Context class.  It should be in the .designer.cs file for your dbml.

public partial class MyAppDataContext : System.Data.Linq.DataContext
    private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
#region Extensibility Method Definitions
    // snip
    public MyAppDataContext(string connection) : 
            base(connection, mappingSource)
    public MyAppDataContext(System.Data.IDbConnection connection) : 
            base(connection, mappingSource)
    // snip

The highlighted lines represent two of the overloaded constructors that can be used to create a context.

Our project had been using the first one by passing in a connection string. To resolve the issue I’m having, I’m going to use the second constructor, passing in our own IDbConnection.

I need to change this:

var context = new MyAppDataContext(ConfigurationManager.ConnectionStrings["MyConnectionString"].ToString());

to this:

var context = new MyAppDataContext(
    new GlimpseDbConnection(
        new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ToString())

After pressing F5, everything worked beautifully and we started seeing our SQL queries come through.

All that’s happening is that we’re manually wrapping our connection in a GlimpseDbConnection. In short, if you have control over the creation of the IDbConnection, you can get Glimpse working with very little fuss. Of course, you’ll need to include Glimpse.Ado in the project that calls this constructor.

I’m sure I don’t need to tell you that you should be using Dependency Injection to inject your IDbConnection where required, making it even easier to implement!

TFS 2012 with Update 2 – Done

At SSW, we make sure we keep ourselves up to date with the latest version of everything, we were one of the first to upgrade our TFS 2010 instance to TFS 2012 RC, then to the RTM when that became available, and finally to Update 1 earlier this year.  Today, I’m happy to announce we have upgraded to TFS 2012.2 (or TFS 2012 Update 2).


One of the major changes with this version is the installation story.  Microsoft has done a lot of work to help ease your upgrade path, so you’ll notice the upgrade is much more straightforward than previous ones.

This update remembered the vast majority of our settings, so there was less need to reconfigure everything after the install.  I like to err on the side of safety though, so I followed our standard steps:

  1. Screenshot our existing configuration
  2. Back up the databases and snapshot the servers
  3. Stop the TFS services
  4. Install TFS 2012 Update 2
  5. Configure TFS 2012 Update 2
  6. Test, test, test!

Before you start

Just as we did last time, the first step was to send an email letting everyone know there would be a TFS outage.  See our Rules to Better Networking for an example of how to do it.

If you’re doing the upgrade, you’ll also need administrator access to the servers. Just as last time, I got promoted temporarily so I could do my work.

Preparation Steps – save your existing configuration

The release notes for TFS 2012.2 claim that all your settings will persist, but just in case, I opened the TFS Administration Console and took a screenshot of each summary page and ended up with 4 images.  This ensures I don’t forget any of the settings if I need them.

Once I’d saved everything I need, I could get going on the install.

Preparation Steps – stopping the servers and backing up

  1. Review the Rules to Better TFS 2012 Migration to make sure what you need to do.  In line with these rules, I took the TFS server offline.
    This is important because we don’t want any checkins or work item changes to come through while we’re halfway through the process.  They may miss the upgrade!

    1. Use TFSServiceControl quiesce to stop all the agents.
      Note: Once again  I got a number of exceptions, but the process automatically retries and succeeds.  The important parts are highlighted in yellow.
      TFS Quiesce
    2. Stop the relevant network services
      TFS Net Stop WAS
    3. Verify that you can’t connect to the TFS server by trying to connect in Visual Studio
      TFS unavailable in VS
      And that you can’t visit TFS Web Access
      TFS Web - 404
  2. As per our rules,  it’s a good idea to run the DogFood Stats queries from Grant Holliday. Document the numbers so you can compare them after the upgrade to make sure you haven’t lost anything.  If you have more than one Project Collection, make sure you do this over every Project Collection you care about.
  3. Back up the TFS and Reporting Server databases as per our rules.
    We have a few relevant databases because we have a number of Project Collections.
    TFS Backup Collections

Installing TFS 2012.2

  1. Because we’re installing from an ISO rather than a physical CD, we mount the ISO using SlySoft’s Virtual CloneDrive (or your favourite alternative).
  2. Run tfs_server.exe from the installation disk or ISO.
  3. Accept the license terms and click Install Now.
    TFS 2012.2 Install
  4. Watch the progress with excitement and trepidation (and coffee)
    TFS 2012.2 Installingssw-coffee

Configuring TFS 2012.2

  1. The Upgrade Wizard should start automatically this time (previously you had to choose it) and it will collect your settings for you!
    Upgrade Wizard collecting settings
  2. When it’s done, you can click Next.
  3. We’re now asked to upgrade an existing database.  Because of the work done with upgrades, the tool should have these details already filled out.
    Upgrading the Database
  4. Confirm you have a current backup, then click Next.
  5. Next, we’re asked for the service account for our Application Tier.  Again, this should already be filled out. Once you’ve provided the password again, check it by clicking Test, then click Next.
    Application Tier settings
  6. Next up, we’re asked if we want to configure SQL Reporting Services.  Make sure the checkbox is checked, then click Next.
  7. Again checking your screenshots, make sure the instance and URLs for your Reporting Services instance are correct (they should be), and click Next.
    TFS Reporting Services config
  8. Next up is the TFS Warehouse database.
  9. The wizard should have already filled this out for you.  If everything is correct, click Next.
    Warehouse Database settings
  10. Next, you’re asked for your Analysis Services instance.  Check the instance name before clicking Next.
  11. Next, we’re asked to provide an account that the Reports will run as.  Again, this should already be filled out by the wizard, but you’ll have to provide a password. Do so, then click Next.
  12. Next we’re asked if we want to configure SharePoint for TFS, we do, so we’ll make sure the checkbox is checked and click Next.
  13. Once again, the wizard should have kept all our existing settings.  We’ll check they’re correct by clicking Test, then click Next.
    SharePoint settings
  14. On the next screen, we’ll get a summary of all the options we’ve chosen.
  15. Go through them carefully to make sure everything is correct, and click Verify to check.
    TFS config confirmation
  16. Your Verify step may highlight issues such as restarts required.  I once again got this issue and had to reboot the server before continuing.
    As per our upgrade to the RTM, I got stuck in a reboot loop and had to follow Steve Wiseman’s advice to break out of it.
    Once fixed, I had to click Configure Installed Features on the Application Tier node then choose Upgrade to start the wizard again.
  17. Once the readiness checks pass, click Configure
    Readiness Checks
  18. Wait patiently (again with coffee) while the upgrade goes through its steps.  When finished, click Next.
    Final Configuration
  19. Once the TFS upgrade has finished, the Upgrade Wizard will upgrade each of the Project Collections. Be patient while it does this.
    Project Collection Upgrades
  20. At this point I ran the Dog Food Stats again (as per step 9) and checked that nothing had changed too much.  This time, all the numbers were exactly the same which is reassuring

Additional steps

  1. I also upgraded Team Foundation Server on our Build Servers by installing the upgrade and checking the settings were the same.
  2. I had to reconfigure our Build Agent to get it working again – it was running under the wrong account.


After the final steps were completed, we went through the following tests to make sure everything was up and running again.

  1. Open Visual Studio and connect to TFS
  2. Do a Get Latest
  3. Make a change and check in
  4. Trigger a build and wait for it to succeed
  5. Check TFS Web Access is working by navigating to the TFS URL
  6. Check the Reporting Services are still working by navigating to the reporting URL

All the tests passed without a problem, so we’re up and live on TFS 2012 Update 2!

There is a lot of goodness in this update for everyone – have a look at the blo

Next Page »