01 May 2007

Programmatically Download Attachments from TFS

I created this short snippet of code the other day in reference to a forum question on how to retrieve the linked items for a given work item.  The code below uses the TFS Object Model to retrieve a specific work item (in this case, item #16) and save all attachments to the local file system.

Code Snippet
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using System;
using System.IO;

namespace DTTFSLib
{
public class WorkItemTest
{
public WorkItemTest(string serverName)
{
// Connect to the desired Team Foundation Server
TeamFoundationServer tfsServer = new TeamFoundationServer(serverName);

// Authenticate with the Team Foundation Server
tfsServer.Authenticate();

// Get a reference to a Work Item Store
WorkItemStore workItemStore = new WorkItemStore(tfsServer);

// Retrieve a Work Item by ID - in this case, bug #16
WorkItem workItem = workItemStore.GetWorkItem(16);

// Get attachments
if (workItem != null)
{
System.Net.
WebClient request = new System.Net.WebClient();

// NOTE: If you use custom credentials to authenticate with TFS then you would most likely
// want to use those same credentials here
request.Credentials = System.Net.CredentialCache.DefaultCredentials;

foreach (Attachment attachment in workItem.Attachments)
{
// Display the name & size of the attachment
Console.WriteLine("Attachment: '" + attachment.Name + "' (" + attachment.Length.ToString() + " bytes)");

// Save the attachment to a local file
request.DownloadFile(attachment.Uri, Path.Combine(@"C:\Attachments", attachment.Name));
}
}
}
}
}

 


Note that exception handling and custom authentication have been left out for brevity.


Check out the Essentials of Work Item Object Model MSDN site for more information on the work item object model.

27 April 2007

TFS Exam 70-510 Goes Live w/Study Guide

I just read a post from Rob Caron announcing the availability of the preparation guide for Exam 70-510, Technology Specialist: Visual Studio 2005 Team Foundation Server. He also announces that the exam is now live for anyone interested in pursuing this certification.

26 April 2007

Answering: "When will bug 'xyz' be ready for testing?"

Have you ever been asked any of the following questions regarding work items: Is bug #123 ready for testing yet?, or When will I be able to test bug #456?, or What bugs are in the pipeline that will be ready for testing next?

If you're like me, you've probably answered the above questions at some point in the past something like: "Sure, it's been ready for testing for two days.", or "Bug #456 will be ready for testing after the next nightly build.", or "I don't know what bugs will be coming next, let me run some queries and get back to you."

Now, I'm a huge fan of Team Foundation Server but I hadn't stopped to take the time to put together a couple of relatively simple queries that would not only save myself and my fellow co-workers some time, but also make everyone's job just a little bit easier.  Before I detail the two queries that eliminated the above questions, here's some details on our environments and automated builds.

Currently, we develop projects and push them through four environmental stages:

  1. Development: this is where all developers work on a daily basis - more-or-less isolated from the rest of the world.
  2. System Test: this is the environment that our testers perform their daily testing.
  3. Integrated Test ("Staging"): this is where we test out the integration points among multiple applications.
  4. Production: of course this is the environment in which our daily business runs.

Now, for each of our Team Foundation Server projects, we have three standard build types:

  1. Continuous Integration Build: this build type is automatically executed with each check in and deploys any binaries, files, etc. into the Development environment.
  2. System Test Build: this build type is executed nightly on a scheduled basis.  All binaries, files, etc. are deployed to the System Test environment where our QA/Testers can "work it over" the following day.
  3. Integrated Test Build: this build type merely stages the various binaries, files, etc. to be pushed by the Integrated Test environment via CM processes.

So, back to the original goal of eliminating the original questions above.  To do this, I created two queries named:

  • Work Items Staged for Testing - this query, when ran, returns a list of all work items (e.g. Bugs) that have a State of "Resolved" and an "Integration Integration Build" (displayed as "Resolved in build" on the Work Item's Details tab) beginning with the text "Continuous Build" (the name of our CI build type).  So, basically, this returns a list of all Work Items that have been associated with a changeset that has gone through the CI process, which means it has been deployed to the development environment and will be deployed to the System Test environment after the next nightly build.

  • Work Items Ready for Testing - this query, when ran, returns a list of all work items that have a State of "Resolved" and an "Integration Build" that does not begin with "Continuous Integration Build" and is also not empty.  I do not specifically check for a "System Test Build" in this query because I am assuming that any build type other than the CI build deploys the changes into an environment from which they can be tested.

With the recent acquisition of TeamPlain by Microsoft, we have deployed the TFS portal within our project teams giving our testers a nice web-based interface into TFS.  Now, when they are curious about the state of existing work items, they can run the queries detailed above and get their answers immediately.

One caveat to all of this, if you decide to implement similar queries then you must ensure that your developers associate work items with their changesets when checking in source code (or other files).

Also, your build types must have the <UpdateWorkItems> element in your build scripts set to "true".  This setting is what causes the "Integration Build" value to be updated to the latest build number associated with the work item.

Without the integration of TFS & Visual Studio, these types of queries would be a lot more difficult (if even possible) to build.

17 April 2007

71-510: TS: Visual Studio 2005 TFS Beta Exam Results Are In

As you may have noticed in other posts, the results for the 71-510 beta exam are starting to show up on participant transcripts (on the MCP member site).  If you took the test a couple of months back then you may be able see your results by now.  I checked mine today to find out that I passed the exam.

Now that the beta results are starting to appear, the "live" exam will probably be available soon.  If you're planning on taking the exam, here are a couple of links to help get you started:

06 April 2007

Updated Team Foundation Server Roadmap for "Orcas"

Brian Harry has just published a new post detailing the future "Orcas" release of Team Foundation Server. The post is fairly detailed and he attempts to point out what features are new as well as what will be in the Beta 1 release vs. the Beta 2 release.

The features marked as new include:
  • TFS Best Practices Analyzer - A tool that can be run against your TFS server that will help diagnose configuration errors and tuning possibilities.
  • VSTS Web Access - There's been much written about this already but the new Web Access product from devBiz will be released as a Power Tool in the next 60-90 days.
  • Support for MOSS 2007.
  • Official testing and support for more configurations - This includes clustering, mirroring, log shipping, Virtual machine deployment, and more.
  • Scheduled builds - You can schedule builds to happen at specified times.
  • Improved build agent communication - We replaced .NET binary remoting with WCF web services, simplifying some configuration and security aspects.
  • Ability to run GUI tests as part of a build - Automated builds used to run tests in such a way as to prevent access to a GUI desktop.
  • New checkin policy for broken CI builds - Preventing checkin while the CI build is broken.
  • Offine improvements (Beta 2) - We've signficantly improved the experience going offline and integrated the tfpt online capability into the IDE for going back online.
  • Extranet support for the TFS Proxy - allowing you to access a local TFS proxy with a different set of credentials than the TFS server.
  • Command line help - You can now type "tf command /help" and get a console dump of the usage of that command. This is much more convenient than always being launched into the richer GUI hypertext help when you just want to remember what the options for a command are. You can still launch the GUI help by running "tf msdn". You can get a console dump of available commands by just typing "tf help".
  • Source Control Explorer refresh improvements - This includes less redrawing and reloading but even more important it enables updates based on changes made in other instances of TeamExploror or the command line. That's right, if you checkout a file from the command line, any instances of TeamExplorer you have running on the same machine will automatically refresh.
  • Query builder usability improvements - Drop down filtering based on current project, better MRU lists, column drag & drop, shift-click mouse based multi-column sorting, etc.
  • Attachments improvements - Save button, drag & drop for adding an attachment, multi-select for attaching files.
  • Tooltips on field names contain the field name used for querying.
  • Server side support for deleting work items & work item types (Beta 2) - We didn't have time to do client UI support for it but we plan to release a Power Tool that will take advantage of the new server side feature.

The above list is only what has been flagged as "new" (some of which won't be available until beta 2). See Brian's original post for a complete list of all features.

26 March 2007

Microsoft Acquires TeamPlain!

The buzz of the day in the land of TFS has to be the story of Microsoft acquiring TeamPlain!  Brian Harry has posted the details but the two main points that stick out is that:

  1. TeamPlain will become Microsoft Visual Studio Team System Web Access (sometime around the "Orcas" release).
  2. It is available immediately as a free download for anyone who owns Team Foundation Server.

The focus of TeamPlain is on TFS work items, however, there is also some built-in version control capabilities, SharePoint integration, Reporting Services integration, and some build support (in a future release).

If you currently have users using the Team Explorer client solely for work item tracking, then you should probably at least give TeamPlain a look.

VSTS Guidance Updated

The Patternes and Practices Visual Studio Team System Guidance site has been updated to include a few new items, including:
Here's a list of what else is also available at this site:
The purpose of the Patternes and Practices Visual Studio Team System Guidance project is to build some insightful and practical guidance around using Microsoft Visual Studio Team System. It's a collaborative effort between patterns & practices, Team System team members, and industry experts.

07 March 2007

VS 2005 SP 1 Update for Windows Vista Released

If you've been developing on Windows Vista using Visual Studio 2005 then you've no doubt become all too familiar with the warning dialog that pops up every time you start Visual Studio (assuming you haven't disabled it). This dialog lets you know that your version of Visual Studio may not work as excepted while developing on Vista and that you should install the Visual Studio 2005 Service Pack 1 Update for Windows Vista.

Since the release of Visual Studio 2005 Service Pack 1, this update was available only as a beta release. Microsoft has now released the non-beta version of this update which can be downloaded here.

Check out the following links if you're curious about what issues exist with Visual Studio 2005 and Windows Vista:

03 March 2007

Outlook Add-In for Team Foundation Server

I came across a (free!) add-in a while back that provides integration of TFS Work Items with Microsoft Outlook 2003.  This add-in provides the following features:

  • Create work items directly from e-mail messages.
  • Submit and edit work items.
  • Execute stored queries.
  • Find work items by ID.
  • Export stored query results.
  • Send work item data and query results by e-mail.
  • Does not require Team Explorer to be installed (although you still need to maintain the required end-user CALs).
  • If you have business owners, testers, quality assurance users, etc. that would like to be able to create and/or manage work items within TFS without having to install Team Explorer (or some other 3rd party interface) then check out this add-in.  It's definitely worth a look.

    The current version supports only Microsoft Outlook 2003 but a version for Microsoft Office Outlook 2007 is in the works and planned to be released soon.

    Read more about it here and/or download the add-in here.

    02 March 2007

    New Orcas Features

    Eric Lee has a nice post on some of the new features found in the current Orcas release. There is some really nice stuff coming out with Orcas, especially in the area of Team Foundation Server. Some of these features include:
    • Code Metrics - view various metrics about your source code.
    • Annotation View for Files under Version Control - lets you see who changed what & when?
    • Team Foundation Server Build Definition Editor - quit messing around in all that XML!
    • Build Retention Policy - automatically remove build files from your drop location.
    • Continuous Builds - finally! :-)
    • Build Queues - lets you queue up builds.
    • Folder Differencing - allows you to compare everything within folders.
    • Runtime Control of a Performance Session - control your performance session as it runs.
    • Query View in Performance Reports - construct queries to sort through your performance data.
    • Integration with Work Item Tracking - right-click to directly create a work item within the Performance Explorer.
    • Performance Report Comparison - compares two performance files.

    These improvements alone make for a nice upgrade (in my opinion) but these don't even include the new advancements made in the new .NET Framework.

    Scott Guthrie has also posted on some of the new web development features found in the current Orcas release. Looks like some really nice features for richer HTML/CSS development, better data querying (via LINQ), etc.. Take a look at Scott's presentation slidedeck for more information.

    The Orcas VPCs can be downloaded from here: