09 June 2008

Retrieving Areas from TFS

As a matter of self-inflicted education I’ve decided to create a simple Visual Studio Add-In for exporting and importing Areas and Iterations.  I’m not sure how much practical use such a utility will receive but it offers several areas for advancing my knowledge and, hopefully, helping a few other people out along the way.

Although I haven’t completed the utility yet, I have completed some of the initial utility code.  I thought I would create a few posts as I progress in case anyone can make use of the examples.  For this post, I am posting the code used to retrieve the list of “areas” from a Team Foundation Server

With that said, here is some example code for saving the list of Areas defined for a given Team Foundation Server and Team Project.  The code is a little verbose but should be relatively simple to follow.

using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Server;

namespace TestConsole
{
public class ExportAreas
{
private TeamFoundationServer _teamFoundationServer;
private ICommonStructureService _commonStructureService;

/// <summary>
/// Exports the "areas" defined within the specified team foundation server.
/// </summary>
/// <param name="teamFoundationServer">The team foundation server.</param>
/// <param name="projectName">The name of the team project to export areas from.</param>
/// <param name="filename">The filename to save the exported areas to.</param>
public void Export(string teamFoundationServer, string projectName, string filename)
{
_teamFoundationServer =
TeamFoundationServerFactory.GetServer(teamFoundationServer);

_commonStructureService = (
ICommonStructureService)_teamFoundationServer.GetService(typeof(ICommonStructureService));

List<HierarchyNode> nodeList = new List<HierarchyNode>();

// Locate root structure node for "Area"
NodeInfo areaNode = GetAreaRootNode(projectName);

//String node = _commonStructureService.CreateNode("TEST Node...", areaUri);

// Retrieve the Area nodes XML
XmlElement nodes = _commonStructureService.GetNodesXml(new string[] { areaNode.Uri }, true);

// Recursively build out the list of Area nodes
BuildHierarchicalList(nodes.ChildNodes[0], nodeList, 0);

// Save the areas to the designated text file
StreamWriter writer = new StreamWriter(filename, false);

foreach (HierarchyNode node in nodeList)
{
writer.WriteLine(
new string('\t', node.IndentLevel) + node.Name);
}

writer.Close();
}

/// <summary>
/// Recursively builds a hierarchical list based on the root node passed in.
/// </summary>
/// <param name="rootNode">The root node to start with.</param>
/// <param name="targetList">The target list to add each <see cref="HierarchyNode"/> instance to. This
/// list must be instantaited on the first call.</param>
/// <param name="indentLevel">The indent level - pass in 0 for the initial call.</param>
private void BuildHierarchicalList(XmlNode rootNode, List<HierarchyNode> targetList, int indentLevel)
{
HierarchyNode listNode;

if (rootNode.Name == "Children")
{
for (int index = 0; index < rootNode.ChildNodes.Count; index++)
{
BuildHierarchicalList(rootNode.ChildNodes[index], targetList, indentLevel);
}
}
else
{
listNode =
new HierarchyNode()
{
Uri = rootNode.Attributes[
"NodeID"].Value,
Name = rootNode.Attributes[
"Name"].Value,
ParentUri = GetAttribute(rootNode,
"ParentID"),
Path = rootNode.Attributes[
"Path"].Value,
ProjectUri = rootNode.Attributes[
"ProjectID"].Value,
StructureType = rootNode.Attributes[
"StructureType"].Value,
IndentLevel = indentLevel
};

targetList.Add(listNode);

if (rootNode.HasChildNodes)
{
for (int index = 0; index < rootNode.ChildNodes.Count; index++)
{
BuildHierarchicalList(rootNode.ChildNodes[index], targetList, indentLevel + 1);
}
}
}
}

/// <summary>
/// Gets the specified attribute from <paramref name="node"/>..
/// </summary>
/// <param name="node">The node containing the attribute collection.</param>
/// <param name="attributeName">The name of the attribute to retrieve.</param>
/// <returns>The value of the specified attribute if it exists; otherwise, an empty string is returned.</returns>
private string GetAttribute(XmlNode node, string attributeName)
{
for (int index = 0; index < node.Attributes.Count; index++)
{
if (string.Equals(node.Attributes[index].Name, attributeName, StringComparison.InvariantCultureIgnoreCase))
{
return node.Attributes[index].Value;
}
}

return string.Empty;
}

/// <summary>
/// Gets the area root node.
/// </summary>
/// <param name="projectName">The name of the team project to retrieve the root node from.</param>
/// <returns>A <see cref="NodeInfo"/> object referencing the root area node.</returns>
private NodeInfo GetAreaRootNode(string projectName)
{
ProjectInfo projectInfo = _commonStructureService.GetProjectFromName(projectName);

return LocateStructureByType(projectInfo.Uri, "ProjectModelHierarchy");
}

/// <summary>
/// Locates the desired structure based on structure type.
/// </summary>
/// <param name="projectUri">The project URI to retrieve the structure from.</param>
/// <param name="structureType">Type of the structure to retrieve.</param>
/// <returns>A <see cref="NodeInfo"/> object referencing the root of the desired structure.</returns>
private NodeInfo LocateStructureByType(String projectUri, String structureType)
{
NodeInfo[] nodes = _commonStructureService.ListStructures(projectUri);

foreach (NodeInfo node in nodes)
{
if (node.StructureType == structureType)
{
return node;
}
}

return null;
}

}

/// <summary>
/// This class is used to hold information pertaining to exported areas or iterations.
/// </summary>
class HierarchyNode
{
public string Uri { get; set; }
public string Name { get; set; }
public string ParentUri { get; set; }
public string Path { get; set; }
public string ProjectUri { get; set; }
public string StructureType { get; set; }
public int IndentLevel { get; set; }
}
}

To use the above sample code, just instantiate the ExportAreas class and call the Export method passing in the desired argument values.

07 June 2008

Tech-Ed 2008 – The Final Day

Well, today officially marks the end of Tech-Ed 2008 for me.  I started the morning by sitting on my suitcase in an attempt to compress all the SWAG into a container that was already full at the start of the week :-)  I lost count of how many T-shirts I ended up with and I believe I ended up with three caps along with miscellaneous “toys” that will provide hours of fun for my kids :-)

I attended a session this morning on the Architecture Edition of “Rosario”.  Although I’ve seen most of what was presented, it was nice to see some of the features being developed that are not yet publicly available (with any luck, the new features will be in the next CTP – around the fall timeframe).  Some of the new (i.e. not in CTP12) features include:

  • Architecture Browser - this isn't new from the current CTP but it has been improved quite a bit.
  • Layer Diagram – this is a really cool, new feature that allows you to visually (i.e. graphically) depict the logical partitions in your application (e.g. User Interface layer, Business Logic layer, Data Access layer, etc.).  Once you have the various layers configured, the really cool part starts - Visual Studio can then validate the implementation of the design so code does not cross architectural boundaries inappropriately.  Brian Harry has a nice post on this feature (he demo'd it during the Tech-Ed keynote this week).

I spent the rest of the morning/early afternoon walking around talking to the folks in the MVP area and hitting the Team System guys up for some giveaway items for the Omaha Team System User Group (thanks, guys, for the Visual Studio Team System branded USB drives!).

I mentioned in my first post this week that I was participating in the “Step-it-Up” program with my company (where I attempt to get a set number of steps in per day for roughly 12 weeks).  By the time I arrived back home after Tech-Ed, I had walked a total of 91,316 steps during the week averaging 18,263 steps per day.  Not too bad – the hard part will be keeping up with this pace over the remaining weeks :-)

I learned a lot at this year’s Tech-Ed and made some great contacts.  I’ve also come back with some great ideas for various articles, blog posts, and utilities related to Team System/TFS so I’m looking forward to digging into all of that and getting some items published during the next few weeks.

So, my goals for next year’s Tech-Ed is to present in an interactive theatre or a breakout session.  We’ll have to wait and see if I’m able to pull it off…  Right now, it’s nice to be home :-)

05 June 2008

Tech-Ed 2008 - the Penultimate Day

Day three is done and now we're down to one more day (more like half a day since I have to leave for the airport shortly after lunch tomorrow).

I sat in on another session with Juval Lowy today discussing productivity with Windows Communication Foundation (WCF).  As always, Juval was very lively, entertaining, and informative.

I sat in on another session discussing project management in Team Foundation Server.  It was interesting in that most of the actual project management (e.g. estimation, work item creation, etc.) was actually handled by Excel and then imported into TFS.  The moral of the story (as was stated at least twice) is that you need to be an Excel guru to effectively manage projects in TFS.  I'm hopeful this is something that will change quite a bit in the "Rosario" release.

Most of the day was spent networking with the various Microsoft personnel hanging out around the Team System booths.  It's been great this week being able to put names to faces.

Tonight was also the conference event at Universal Studios.  From the moment we walked through the gate there was food, drinks (beer, pop, water, etc.), desserts, more food, and more beer :-)  Several of the attractions were closed off, including the Mummy ride, Twister, Shrek 4D, and others.  However, the new Simpsons "ride" was really cool.  Watching the T2: 3-D show (for the umpteenth time) was still just as great as ever!  It all made for a great night!

Developer Conference RSS Feed

A while back I created a conference calendar on the Omaha Team System User Group's web site.  As I come across (US-based) developer- or architecture-related conferences, I add them to the calendar.  So, feel free to subscribe to the RSS feed if you're interested.  Note that you will also get notifications of user group events in Omaha :-)

You can also view that actual calendar page here as well.

Tech-Ed 2008 - Day Two

Day two is now wrapped up and I'm taking a short break during day three to write this post.  I'm currently sitting in on Philip Wolfe's Hosting Windows Workflow talk which is going extremely well.  There are about 25 to 30 people in attendance with some very good questions being asked and answered.

I started the morning off yesterday by moderating the BOF session Using Microsoft Team Foundation Server in your Organization which went very wellI also attended various sessions throughout the day including one on durable services using WCF as well as others.

I also spent some time meeting the various Microsoft personnel and other staff (completing Mickey Gousset's trifecta :-) responsible for building and testing the various Team Foundation Server products.  It was great to be able to association some names and faces with the product.  My goal today is to locate and meet the product manager :-)

We ended the day yesterday by attending the ARCast.TV party at TGIF's which was a lot of fun as well (of course :-)

04 June 2008

TFS BOF Session - Check!

I just completed my first Birds of a Feather session here at Tech-Ed 2008.  I moderated the session on Using Microsoft Visual Studio Team Foundation Server in your Organization.   We had a great turnout with around 70-80 attendees in the audience.  The discussions covered a wide range of topics, including:

  • Issues related to upgrading from TFS 2005 to TFS 2008
  • Moving/changing TFS SharePoint servers after the installation has been completed
  • Migrating Visual SourceSafe databases to Team Foundation Server version control
  • Integrating Microsoft Project Server with Team Foundation Server
  • Handling 3rd party controls in your application's automated builds
  • Configuration of Team Projects on your Team Foundation Server(s)
  • Many others

There was some great discussion among the members of the audience - some with similar experiences and others with widely varying experiences.  We also had a Team System MVP in the room so he was able to address several of the issues in detail.

We actually ran out of time before we were able to get through the list so if I can retrieve the questions list from the session room I will post some links for further information on the remaining topics.

Tech-Ed 2008 - Day One

Well, day one of Tech-Ed 2008 is in the books.

The morning started off with Bill Gate's final public keynote as CEO of Microsoft.  The first portion of the keynote was spent watching a video that enacted what Bill's last day of work might be like at Microsoft.  It was a entertaining video with a lot of high-profile cameos by people such as Warren Buffet, Hillary Clinton, Barack Obama, John McCain, Bono (of U2), Matthew McConaughey, George Clooney, Al Gore, et. al.  Afterwards, Bill, along with the help of some others, spent some time covering various technologies including Silverlight (get product name), Visual Studio "Rosario" (including some cool architecture features not yet available in the CTP), SQL Server 2008, Microsoft Robotics, etc.  There were a few product-related announcements made during the keynote but nothing major.  You can read about them on Somasegar's blog.

One of the sessions I attended was Visual Studio Team System: Today and T tomorrow by Brian Harry.  I was looking forward to meeting Brian because of my personal interest in Team Foundation Server.  I finally caught up with him later in the day and got the chance to introduce myself and speak with him for just a minute (there was a line behind me).  So, check that goal off my Tech-Ed "to do" list :-)  There weren't any real surprises in Brian's session if you've been keeping up with the Visual Studio 2008 Service Pack 1 Beta and Visual Studio "Rosario" but it was still an informative and interesting session.

I also attended the session .NET Interface-Based Programming by Juval Lowy.  He spent his time talking about how we should be developing interface-based software instead of object-oriented software because interfaces are the path to code reuse.  He made some very good points during his session which I plan on investigating a great deal over the coming weeks.

Although I don't really work with Windows Workflow Foundation (WF), at least not yet, I attended the session Introduction to Windows Workflow (services) by Ron Jacobs.  Mainly because I've watched quite a few of the ARCast.TV videos in the past with Ron and I wanted to see him in person.  He does as great of a job presenting in person as he does on "TV" although I felt he should have plugged Philip Wolfe's TLC session More Windows Workflow Foundation Hosting Options than You Thought when hosting-related questions came up :-)

All in all, a great start to the Tech-Ed week!

02 June 2008

Tech-Ed 2008 - Day Zero

After roughly eight hours of travel time (including layovers) I finally made it to Orlando.  This is my third time here in Orlando for a Microsoft conference (one PDC and, now, two Tech-Eds) and it's nice to be back.  This year I am traveling with another Tech-Ed veteran, and co-worker, Philip Wolfe.

We basically went straight from the airport to the hotel just long enough to drop our luggage off and head over to the conference center.  We planned on attending the INETA mini-summit and arrived at the conference center about 15 minutes before the end of the session.  However, the security personnel would not let us pass through to the conference room until we went through the registration line.  There really wasn't a line so we were through fairly quickly.  We ended up getting to the mini-summit right as it was ending so we were still able to get the swag as well as meet some of the INETA personnel (e.g. Nancy Mesquita, David Silverlight, etc.) which allowed me to finally put some faces with names.

Afterwards, we headed on over to the Glo Lounge for the Party with Palermo.  We arrived pretty early and there were already quite a few people there.  Shortly after arriving, there was a piñata game with the idea being that various attendees would get a chance at breaking the piñata and releasing the prizes imprisoned within it.  However, the first participant knocked the piñata off the hook so the piñata was ripped open and the various prize tickets thrown out on the floor.  I ended up with a few Starbucks gift cards, however, one lucky attendee walked away with an XBox 360.

After hanging out at the Glo Lounge for a while we ended up heading out in search of some grub.  We ended up at Adobe Gila's where I has some great chicken enchiladas.

I'm looking forward to a great week of learning and networking starting tomorrow morning with the keynote from Bill Gate's.  Also, I will be moderating a Birds of a Feather (BOF) session on Wednesday (Using Microsoft Visual Studio Team Foundation Server in your Organization) and Philip will be presenting the Interactive Theater Session More Windows Workflow Foundation Hosting Options than You Thought on Thursday.  It's going to be a fun week!

28 May 2008

Omaha Team System User Group

Well, the 2nd Omaha Team System User Group meeting is, as they say, in the books!  We had a great turnout with about 25 attendees that showed up to listen to Mike Douglas speak about TFS build automation and the coolness factor of incorporating (authentic) stoplights into the build process.

Mike also demonstrated his latest CodePlex contribution - Team Deploy.  Team Deploy is a set of custom MSBuild tasks that provide functionality for deploying MSI files as well as controlling X10 devices (e.g. stoplights, lava lamps, etc.).  Some of the tasks included are:

  • Install Task - installs an MSI on a remote machine.
  • Uninstall Task - uninstall an MSI from a remote machine.
  • Kill Process Tasks - kills a process on a remote machine.
  • Deploy Task - utilizes a deployment script to automate the installation of MSIs on a set of remote machines.  This is the most common task to be used in the collection.
  • Start Service Task - starts a Windows Service on a remote machine.
  • Stop Service Task - stops a Windows Service on a remote machine.
  • Device Controller Task - allows you to control X10-enabled devices from your builds.

Once again, our meeting was sponsored by Farm Credit Services of America which provided pizza, pop, a great place to mingle prior to the presentation, and an excellent meeting room for the presentation.

You can download the PowerPoint slides here.

14 May 2008

VS 2008 & .NET 3.5 SP1 Beta

The beta release of Service Pack 1 for Visual Studio 2008 and .NET Framework 3.5 is now available for download.  There are a ton of changes in this update.  Some of the high-level changes include:

  • Performance improvements for WPF-based applications (with no code changes)
  • Improved designers for building WPF applications (can't wait to see this!)
  • Full support for SQL Server 2008
  • The introduction of the ADO.NET Entity Designer (very cool!)
  • Improvements to Team Foundation Server
  • Improvements for web development
  • Improvements to the C# and VB.NET experience in the IDE

For example, one of the interesting improvements on the client side is the introduction of the ".NET Framework Client Profile".  This option is set at the project level and allows the use of .NET Framework binaries that are commonly used by client-side applications (e.g. Windows Forms, WPF, and WCF).  It does not include the ASP.NET binaries, for example.  This option allows you to build client-side applications that can make use of the smaller .NET Framework Client, which is smaller, and therefore quicker to download and install.

There are also a ton of modifications relating to Team Foundation Server (which is where a lot of my personal interests are focused).  One of the (many) changes include version control of unbound files.  While this may not seem all that exciting to some, how many times have you opened a TFSBuild.proj file and stared typing only to realize that the file is not automatically checked out like other files that make up a solution?  Although I haven't tried this beta out (yet) I would hope this feature would resolve this issue.

There are a lot of features to test out so I hope to blog about some of these in the near future.  You can read the full details on the the Team Foundation Server updates here from Brian Harry.

To see what exciting changes are included in Visual Studio and the .NET Framework, check out this post by Scott Guthrie.

You can read Microsoft's official release regarding the beta release here.

The expected release date of the Visual Studio/.NET Framework 3.5 SP1 is summer, 2008.