Steve Lange @ Work

Steve Lange's thoughts on application lifecycle management, Visual Studio, and Team Foundation Server

February, 2013

  • Steve Lange @ Work

    Finding What’s Out of Date In your Workspace


    A couple of customers have asked me about this in the past couple of weeks:  “How can I tell in my workspace, how far out of date are my files?”

    TFS knows if your file is out-of-date and will tell you simply by showing you a “No” in the Latest column in Source Control Explorer:

    Source Control Explorer

    But what if you want to know how far out of date your file is?  You can see this by accessing the properties of the file (right-click, select Advanced->Properties):

    File properties

    As you can see in the above screenshot, I’m one version behind.

    Easy, right?

    But what if I want to know this for all the files in my workspace?  Using the built-in mechanisms, I’d have to look at the properties of each file that shows “No” in the Latest column.  That could take a while!

    As a side note, if I don’t care how far out of date I am, but I at least want to know all the files that are out-of-date, I could use the /preview switch on the command line tf get:

    command line

    Notice that a.txt and d.txt in the command line correspond with what’s shown as out-of-date in the first screenshot. (BTW, nothing actually happened because I specified /preview.  And the “Replacing” tells me that these files need to be replaced, or “caught up”.

    However, let’s assume I want to know the workspace and server versions for all my files that are outdated in my workspace.  There’s not a very convenient manner to do this without several clicks, but it’s surprisingly easy through the TFS API.

    Here’s a quick, full sample console application that:

    1. Connects to my TFS server (only works for “on prem” TFS, not TF Service (it will work, but not by using WindowsIdentity))
    2. Grabs your workspace
    3. For each file in your workspace, checks to see if the workspace version is different than the server version.
    4. Spits everything out to the console.

    The code isn’t anything special (I’m not a developer by trade), but it works.

    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.VersionControl.Client;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Security.Principal;
    using System.Text;
    using System.Threading.Tasks;
    namespace WorkspaceVersions
        class Program
            private const string _TfsUrl = "http://<myTFS>/defaultcollection";
            private const string _TfsProject = "$/<myproject>";
            private const bool _OnlyListOutOfDate = true;
            static void Main(string[] args)
                Print("Connecting to TFS..");
                // Connect to the team project collection and the server that hosts the 
                // version-control repository. 
                TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
                   new Uri(_TfsUrl));
                VersionControlServer vcServer = tpc.GetService<VersionControlServer>();
                // Get workspace versions
                ListWorkspaceVersions(vcServer, _TfsProject);
            /// <summary>
            /// Silly convenience method for printing a line of text to the console.
            /// </summary>
            /// <param name="text"></param>
            private static void Print(string text)
            private static void ListWorkspaceVersions(VersionControlServer vcs, string project)
                Print("Getting workspace..");
                var workspace = vcs.QueryWorkspaces(null, WindowsIdentity.GetCurrent().Name, 
                Print("Getting working folder for the project..");
                var folder = workspace.Folders.First(f => f.ServerItem == project);
                Print("Getting local versions..");
                List<LocalVersion[]> items = workspace.GetLocalVersions(new[] { 
                    new ItemSpec(folder.LocalItem, RecursionType.Full) }, 
                if (_OnlyListOutOfDate)
                    Print("NOTE: Only listing items which are out-of-date");
                foreach (LocalVersion[] locals in items)
                    foreach (LocalVersion item in locals)
                        int serverversion = vcs.QueryHistory(
                            new ItemSpec(workspace.GetServerItemForLocalItem(item.Item),RecursionType.Full),
                        if ((_OnlyListOutOfDate && (serverversion != item.Version)) || _OnlyListOutOfDate == false)
                            Print(String.Format("   Server: {0}, Local: {1}", serverversion, item.Version));

    If you are comfortable in the command line, this may work out well for you.

  • Steve Lange @ Work

    Denver Study Group, by the Denver Visual Studio User Group


    2/13: Update – New meeting location!

    The local user group here in town has set up a new study group, kicking off tomorrow (Feb 7th).  For full details, go here, but below are the core details.

    The Denver Study Group is a sub group of Denver Visual Studio User Group.


    Thursdays, beginning February 7, 2013 (first course for 6 weeks, then repeat for next course)
    5:30 p.m. - 7:30 p.m. Limited to First 20 Attendees!  


    Microsoft Store, 303-824-6772
    Park Meadows Mall, 8505 Park Meadows Center Dr., Lone Tree, CO 80124,
    Store is near the center of the mall, Zone B, Upper Level, between Macy's and Forever 21
    Meeting space is near the middle back portion inside the Microsoft store

    UPDATED LOCATION (see below)   

    Innovation Pavilion, 9200 East Mineral Ave., Centennial, CO 80112

    North of Park Meadows Mall, between E. Dry Creek Rd. & E. County Line Rd., W of I-25)
    - Plenty of free parking, Enter the front lobby (doors locked after 7:00 p.m.)
    - Check the white board for room number (probably, 3rd floor, Suite 310 or 385)

    Using Pluralsight videos: one month free pass for first time attendees
    First Course: Building Applications with ASP.NET MVC 4 by Scott Allen
    Watch Videos, Code, Discuss (no purchase necessary)
    Optional: bring your own pc (free Wi-Fi available)
    Join us for our first Denver Study Group --
    FMI: read the details below


    The Study Group meets for the express purpose of gathering developers together on a series basis to watch, code, discuss, and learn from high quality video training along with others of a like mind.
    During the Study Group meetings, the training videos are shown in a web browser via a streaming service and displayed on a large screen audio/visual presentation system for all participants to watch and hear together.


    Video training helps us in our group bring experienced and highly rated training professionals directly into our group at a time and place of our choice -- and for free! More than that, it provides us with opportunities to select the specific training we need to be delivered via video and supplement it with coding in a group setting and interactive discussions learning together with our own peers locally. This gives us the best of both worlds - expert training and group interaction - delivered to fit our needs.
    Video training provides an excellent, cost-efficient alternative to live training programs by using a vast training library which has helped thousands of developers worldwide. When we add our group members to code and discuss together, you get even more than you could by watching the videos solo.


    Thursdays, 5:30 pm – 7:30 pm MST, approximately 2 hour meetings once each week
    Watch 45-60 minutes of course video at each meeting
    Work 20-30 minutes on ad-hoc exercises and code together as a group related to the video just watched
    Discuss 20-30 minutes in a round table format related to the video just watched
    Approximately 5-6 consecutive weekly meetings will be completed to go through a course
    Break between courses 1-4 weeks and then repeat for next course
    Depending on the course and the needs of the participants, the watching/coding/discussion times  will vary, sometimes considerably
    Depending on each course, length of each weekly meeting and consecutive meetings for a course may vary
    Holidays, other special days, weather, and venue use, may cause changes to the planned schedule
    We will plan for each course from one to six months ahead of scheduled venue space needs and  communicate those dates and times to ensure our space reservations and placement on the venue  events calendar

Page 1 of 1 (2 items)