in

Utah .NET User Group

Home of Utah's professional .NET developers.

Justin Long's Blog

May 2007 - Posts

  • Getting Started with the Team Foundation Server API

    Recently I've been dealing a lot with writing application that tie into Team Foundation Server (TFS) so I thought I would share some things about it.

    Integrating your .Net applications with TFS is actually extremely easy. Microsoft has provided a nice API for you to use that is "somewhat" documented in the Visual Studio .Net SDK (version 4).

    Getting Started Requirements:

    • .Net Framework 2.0.
    • Team Explorer (You can get it with the TFS Trial download).
    • 32-Bit Windows (Unfortunately the DLL's are compiled for x86 only).

    Team explorer installed the TFS API's in your ...\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies directory by default.

    Since this is just getting started I'm going to keep this demo very basic and just list all of the files that are in TFS's source control service.

    First off you'll need to create a new .Net project (Assuming you'll be using VS.Net, I'll be using a C# Console Application).

    Next you'll need to add your references (You'll have to browse to these on your hard drive, there in the PrivateAssemblies directory I mentioned above). You'll to add the following assemblies:

    • Microsoft.TeamFoundation.Client.dll - This gives us everything we need to connect to TFS.
    • Microsoft.TeamFoundation.VersionControl.Client.dll - This gives us access to the source control server in TFS.

    Now you'll need to add your using statements:

    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.VersionControl.Client;
    

    Next we need to connect to our TFS server (I'll be doing this in my Main method since I'm using a console application). We can do this by asking the TeamFoundationServerFactory for our server like this:

    TeamFoundationServer teamFoundationServer =
    TeamFoundationServerFactory.GetServer("MY-TFS-SERVER");

    Then we'll need to ask our TFS server for its version control service like so:

    VersionControlServer versionControlServer = (VersionControlServer)
    teamFoundationServer.GetService(typeof(VersionControlServer));

    And now we're set, all we have left to do is ask the version control server for its items using the root path and tell it to use fill recursion and display them:

    ItemSet items = versionControlServer.GetItems("$/", RecursionType.Full);
    foreach (Item item in items.Items)
         Console.WriteLine(item.ServerItem);
    

    It's as simple as that!

    Hopefully this will get some of you excited about working with the TFS API. This is just one of the many things I've planned on writing about so stick around!

  • Visual Studio 2005, Vista Install Nightmare!

    I'm just going to start off saying that I've installed Visual Studio 2005 almost a dozen times on Windows Vista with no issues... Tell today.

    My company recently gave me a laptop to use so naturally the first thing I do is blow it away and install Windows Vista Ultimate on it. After the fresh install do the windows update, install Office 2007 so I can check my email and then I proceeded to install Visual Studio 2005... To my surprise it fails telling me I need to install Windows XP Service Pack 2. So after a short WTF moment I start to run the setup in all the compatibility modes I can find with no success, I guess I'm off to search the internet (Weeee!).  So after an hour or so of finding nothing I finally come across this form posting: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1186197&SiteID=1

    Now I was getting excited, this looks like the fix. I follow its instructions and edit my registry to trick the setup into thinking I'm running Windows XP SP2. Then I run the install again to see if it'll work and it does.  But then I get the next error talking about MSXML 6, this was a little disappointing but I was ok with it because the same forum post mentioned a fix for this as well. So I go back and follow the instructions to install DExplorer then go back to my VS 2005 setup. Everything's looking good and then... Failed... same MSXML error, I try rebooting just in case there is some COM registration issues going on, try again... same error. So now it's back to the internet to try and find another workaround and ended up coming up with this forum post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=73806&SiteID=1

    Even though this was for Vista beta 1 I thought I would give it a try, I copy all the files locally and... no success. At this point I'm becoming extremely frustrated and start venting to my co-workers and one of them (Fabio for those that may know me/us) suggested that I should try installing it under another user profile so at this point I give it a shot. And it works!!! The only difference between the users is one is a local user the other (that didn't work) was a domain user but both are local administrators.

    Now this leaves us to wonder if I would have had to go through all of the other crap or if everything would have worked find had I used the other user from the get go...

    Hopefully this information may be useful to someone and I help you save a couple hours of pulling out your hair...

Copyright © 2000-2007, Utah .NET User Group
Powered by Community Server (Commercial Edition), by Telligent Systems