Community TFS Build Extensions – December 2011

logosansshadow

We’ve just shipped the next stable release of the Community TFS Build Extensions.

This is a significant release for us following over 130 changesets since our September release. Once again we’ve addressed feedback from users, fixed bugs and added new features.

Highlights of this release include

  • Visual Studio 11 support
  • Community TFS Build Manager (alpha) — blog posts to follow on this.
  • New Activities
  • Windows Azure Activities
    Amazon Web Services Activities
    SharePoint and ClickOnce Activities
    SSH Activities
    Lab Management Activities
    Many Workflow Utility Activities

    Once again, Stuart (link to follow), Mathias, Tiago, Guillaume, Richard and Jakob, thanks for your continued dedication!

Mike

Merry Xmas Dogs

image

I recently received a payment from advertising revenue on two open-source projects I run (MSBuild Extension Pack and Controlled Vocabulary). I’ve matched that payment and donated all proceeds to DogsTrust. Thanks for the support…

“Thank you so much for your kind donation!

Your support will help us to look after the thousands of dogs who come into our care each year.

But that’s not all you’re helping us to do…

Each year, with your help we care for over 16,000 dogs at our nationwide network of 17Rehoming Centres. No healthy dog is ever destroyed.

We run subsidised neutering campaigns in areas of the UK with the most acute stray dog problems.

Our Education Officers give thousands of classroom presentations every year. Free teaching resources are made available to all schools in the UK.

Our FREEDOM project helps pet owners who are fleeing domestic violence by fostering their animals while they start a new life.

The HOPE project gives preventative veterinary care to dogs belonging to homeless people.

We advise government on any matters concerning dog ownership.

We have established a charity in Ireland that runs a rehoming centre in Dublin.

We assist overseas animal welfare charities by training their staff in best practice.

All this work is solely funded by generous people like you. So thank you once again for your kindness and your goodwill towards the dogs in our care!

Thank you!”

MSBuild Inline Tasks to the rescue

A colleague (Pål Bendiksen) recently asked if there was an MSBuild task available to checkin pending changes in a Team Foundation Server workspace and get the check-in id. Looking at the MSBuild Extension Pack I saw no solution. Another solution would be to exec out to tf.exe, however there are complexities with scraping the output of that (…take note of the new ConsoleOutput and ConsoleToMSBuild properties exposed in the upcoming 4.5 version of the Exec Task. which make consuming output easier).

A short while later Pål reminded me that from MSBuild 4.0 you can create inline tasks. See: MSBuild Inline Tasks and Walkthrough: Creating an Inline Task for some great guidance.

Inline tasks are a great feature to leverage if you don’t have a compiled task immediately available. Once you get the time though, try get it added to your compiled task library where you can ensure your code meets any quality gates you have set, e.g. Stylecop, Code Analysis, Code Contracts etc…

Here’s the simple implementation which ‘gets the job done’…

<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <UsingTask TaskName="CheckinTask" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
        <ParameterGroup>
            <collectionURI ParameterType="System.String" Required="true" />
            <workspaceName ParameterType="System.String" Required="true" />
            <CheckinID ParameterType="System.Int32" Output="true" />
        </ParameterGroup>
        <Task>
            <Reference Include="Microsoft.TeamFoundation.Client" />
            <Reference Include="Microsoft.TeamFoundation.VersionControl.Client" />
            <Using Namespace="Microsoft.TeamFoundation.Client"/>
            <Using Namespace="Microsoft.TeamFoundation.VersionControl.Client"/>
            <Code Type="Fragment" Language="cs">
                <![CDATA[
                        CheckinID = 0;
                          Uri serverUri = new Uri(collectionURI);

                        TfsTeamProjectCollection collection = new TfsTeamProjectCollection(serverUri);

                        VersionControlServer versionControl = collection.GetService<VersionControlServer>();

                        Workspace[] wsList = versionControl.QueryWorkspaces(workspaceName,
                versionControl.AuthorizedUser, System.Net.Dns.GetHostName());

                        if (wsList.Length != 0)
                        {
                        Workspace ws = wsList[0];
                        CheckinID = ws.CheckIn(ws.GetPendingChanges(), "Build server");
                        }
                ]]>
            </Code>
        </Task>
    </UsingTask>

    <Target Name="Default">
        <CheckinTask collectionURI="http://M4600:8080/tfs" workspaceName="M4600">
            <Output TaskParameter="CheckinID" PropertyName="ID"/>
        </CheckinTask>
        <Message Text="CheckinID = $(ID)"/>
    </Target>
</Project>

MSBuild Extension Pack November 2011 Release

The November 2011 release of the MSBuild Extension Pack is now available for download.

The November 2011 release contains

  • version 3.5.10.0 for those using .Net 3.5
  • version 4.0.4.0 for those using .Net 4.0

This release consolidates 55+ changesets and contains the following high level changes

  • Around 17 new Tasks / TaskActions
  • Around 22 improvements covering Documentation, new attributes and behaviour
  • Around 16 bug fixes
  • Zero backwards compatibility breaks Smile

For full details of all changes please see the Change Sets listed on CodePlex.

Thanks for all the support and suggestions that have made this release possible. We’ve now surpassed 76 000 downloads…

image

image

image

Mike#

Thank you for all your support Rangers…

imageIn April I was honoured to be nominated as the ALM Rangers Champion of Champions. Yesterday I heard that my peers had once again voted for me and I’ve once more been named Champion of Champions. I get to keep my place on the ALM Rangers MSDN page and am joined by Martin and Robert!

I’d like to thank the external ALM Rangers for their vote and thank all ALM Rangers for the time and dedication you all pour so passionately into this programme. It’s an honour, a learning experience and best of all great fun to collaborate with so many people throughout the world.

I know we are all heads down on the DEV11 Readiness wave and the next 3 months pose a massive challenge… I wish you luck on all your projects and look forward to experiencing the challenge with you.

Mike

Community TFS 2010 Build Extensions – September 2011

We’ve just shipped the second stable release of the Community TFS 2010 Build Extensions. We shipped our first release in July and this release contains 28 changesets which provide new functionality and address a lot of feedback from our first release.

We were hoping to release a set of Azure and Amazon Web Services activities with this release, however they have not made the cut. We’ll endeavour to address this in our next release, ETA December 2011.

Please note that we’ve taken a backwards compatibility break in this release for the VsDevEnv task which Tiago Pascoal has significantly revamped (we already support VS11 Smile)…

Apologies for the slight delay in this release, but the contributors have been amazingly busy in the last few months. Mathias, Tiago, Guillaume, Richard and Jakob, thanks for your continued dedication!

Mike

Controlled Vocabulary 1.5.3

This version provides support for SharePoint Discussion Posts — Download.

Thanks to Willy-Peter Schaub and Robert Maclean for the idea and testing.

Note that the Conversation does not change once the subject is set. You can see the affect of this in the following two sequences. I think this may be an Outlook bug, but feel free to correct me!

Sequence 1

  • User enters subject
  • User clicks away from the subject field so its registered
  • User uses Controlled Vocabulary to set the subject
  • SNAGHTML2aa1f085

Sequence 2

  • User uses Controlled Vocabulary
  • User adjusts subject
  • SNAGHTML2aa29f98

Build Trigger Management in Team Foundation Build 2010

Even though Visual Studio 2010 has been out for some time, I encountered an interesting question on a discussion list recently. The question was basically, “What happens if I check into a folder which is mapped to a Gated and a CI build?” I didn’t know the answer off hand (I’m not sold on Gated Check-in builds, but that’s worthy of its own blog post) so I did a bit of testing. Before I could start another question came up which was, “What happens if I check into a folder which is mapped to multiple CI builds?”. That one I did know, but I think it’s worth covering these questions and a few others in more detail.

Gated Check-In (GC) vs. Continuous Integration (CI) Builds

If you have GC and CI builds mapped to the same Source Control folders, a check-in to those folders will only trigger the GC build. When the GC build completes successfully, it will check in the changes with the special ***NO_CI*** comment to prevent any CI builds being triggered.

image

Note, if a user decides to override a GC build, the check-in will trigger the CI build(s) unless they enter ***NO_CI*** somewhere in the check-in comment.

imageWhat if you want to use the power of gated check-in to protect your source code repository, but then run CI builds as a result? For example you may configure a fast GC build to perform an incremental get and run a subset of tests to validate the check-in. If the GC build completes successfully you want to move to the CI level of builds. Fortunately there is a way to do this. You need to edit the SyncWorkspace activity in the build template and set NoCIOption="false" on it. Once that is set, your GC build will check-in without the ***NO_CI*** comment and your CI builds will trigger after the GC build completes successfully. (thanks to William Bartholomew for the tip)

CI Builds vs. CI Builds

So what happens when a folder is mapped to multiple CI builds. In this case multiple builds are triggered. This is by design as it’s perfectly valid for these builds to be performing different operations on the code base. These builds will be queued and handled by your controller / agent configuration independently.

GC Builds vs. GC Builds

Finally, if you have multiple GC Builds configured to the same folder(s), you will be presented with an option of choosing which GC Build to trigger.

SNAGHTML2a67d602

I think that covers all the scenarios and I hope that gives you a better understanding of the build triggers in Team Foundation Build 2010.

Mike

Using Work Item Tracking Search in the Team Foundation Server Power Tools

The current out the box experience of work item searching in Team Foundation Server 2010 involves putting together a query, probably spanning a few rows, and then executing it. Then you may save that query for later as something like “My Bugs” or “Created by Me”. Then you find that you frequently want to tweak those queries to search for other things, maybe you save those too, soon you end up with lots of saved queries cluttering your system.

The Team Foundation Server Power Tools August 2011 release provides a new Work Item Tracking Search feature which aims to address the ad-hoc querying this is currently a little cumbersome in the product.

Simplified Experience

Out the box in TFS 2010, if I want to search for all work items assigned to me I’d craft a query similar to that below and then press Run.

image

With the Power Tool I can now just type A=@Me

image

That’s a lot easier!

I’m not going to repeat the help file, so if you haven’t seen it, its a must read and gets installed with the Power Tools to

  • YourInstallPath\Microsoft Team Foundation Server 2010 Power Tools\Help\WorkItemSearch.mht

    Samples

    Given my very simple dataset of two work items (one bug and one task) let’s see what we can do to find them

    Its worth remembering the shortcuts we can use (as mentioned in the help file)

Shortcut Field
A AssignedTo
C CreatedBy
S State
T WorkItemType
Find everything assigned to me in a State of new
  • A=@me S=New
  • A=@me State=New
  • A=@me System.State=New These are all the same and provide the single result expected.

image

Find everything assigned to me of type Bug
  • A=@me T=Bug
  • A=@me WorkItemType=Bug
  • A=@me System.WorkItemType=Bug
  • A=@me “Work Item Type”=Bug I would expect these to all be the same, however the second query returns an error

—————————
Microsoft Visual Studio
—————————
Team Foundation Error

TF26027: A field definition WorkItemType in the work item type definition file does not exist. Add a definition for this field or remove the reference to the field and try again.
—————————
OK  
—————————

Given that System.State worked, this looks like an odd bug. Note that using AssignedTo=@me gives the same error, but System.AssignedTo works.

animal, bug, insect, ladybird icon I’ve done a little testing with other fields and it looks like any CamelCased field will require a full declaration to work.  Odd bug, but I think that’s the case Smile. Anyway, it’s easy to work around.

It’s also worth remembering the Operators we can use

Operator Description

(equals)
The EQUALS operator. Use this operator to search for exact matches of text.
:
(colon)
The CONTAINS operator. Use this operator to search for partial matches of text.
-
(minus)
The NOT operator. Use this operator to exclude work items that contain certain text. The NOT operator can only be used with field names.

The help files says that by default if we use words “or phrases in quotes” then, “The results displayed contain any work items where your keywords or phrases are found within the Title, Description, or Repro Steps fields.”

I suspect this set was specified for performance reasons. We all know that the history field is what we will most likely need to search to find that work item which does not want to be found. Since we can actually search any field and use operators, this is easily done.

Find everything assigned to me of type Bug where the History filed contains the word sunny

A=@me T=Bug History:sunny

image

Fantastic!

Hopefully that gives you some ideas on how to make use of this feature. Take care to not use spaces between operators and fields, e.g. A= @me will not work. Note the space between = and @. Also note that the search bar will remember your history.

image

Again, those folk who have spent their spare time getting this too us should be commended. I look forward to seeing better integration and features in TFS11. It would be nice to pin some of those searches wouldn’t it… Winking smile

Mike

Using Rollback in the Team Foundation Server Power Tools

Team Foundation Server 2010 provided a much better rollback experience for users via the tf rollback command. In ‘TFS11’ this functionality will be baked into the UI, though it seems that the Visual Studio UserVoice site is bearing some early fruit as the TFS team has decided to provide rollback in the TFS2010 UI via its Power Tools delivery vehicle.

Rollback in the UI can be found in the Team Foundation Server Power Tools August 2011 release.

Important

  • It’s important to remember that this Power Tool doesn’t replace the tf rollback command. The Power Tool only operates in /recursive mode and doesn’t provide support for advanced options like /keepmergehistory and /lock.
  • It’s also important to understand how Rollback works. From MSDNYou can use this to roll back the effects of one or more changesets to one or more version-controlled items. This command does not remove the changesets from an item’s version history. Instead, this command creates in your workspace a set of pending changes that negate the effects of the changesets that you specify.

UI Integration

Its available from two areas in Team Explorer, with each providing a slightly different experience

Source Control Explorer

If you right-click on a folder or file in SCE you will now see the [Rollback…] menu.

image

This will be disabled if there is an incompatible pending change (like a move or delete) on the item being selected. If you try rollback a changeset which contains incompatible pending changes, you will get the familiar message: TF203015: The item $/xyz/A.txt has an incompatible pending change.

If there are no incompatible changes you get the Rollback dialog which, while providing a wide range of options to configure, allows you to rollback a single, range or version.

image

Once you have configured your options, click Rollback and unfortunately you will get no feedback. Pretty much nothing happens, not even a refresh of SCE. You will now need to view your Pending Changes window to see what the rollback has affected.

History

image

Similar to the Rollback in SCE, when you click on Rollback Entire Changeset you will get no feedback. You must track down your Pending Change window to see what eh result is.

Tips

  1. Remember that Rollback will create a set of pending changes. You need to commit these for the rollback to take effect.
  2. If you are rolling back to a specific changeset version, be aware that files which were not created at that time will be deleted.
  3. History allows you to selectively multi select (something a Power Tool is not allowed to change). If you use multi select in History, you will actually be rolling back a Range of changesets from the largest to smallest selected, e.g. in the following example it appears that I am able to selectively rollback 3 changesets
  4. image

    but the resulting dialog shows that we are actually rolling back all changesets in the range

SNAGHTML38ffe1

4. REVIEW your pending changesets before checking in.

There are a few other rough edges, but overall this is a great addition to the Power Tools and those who spent their spare time getting it to us should be commended.

Follow

Get every new post delivered to your Inbox.