Posted by Stuart Preston on May 2, 2010 under Team Foundation Server |
There are many more sophisticated ways of achieving this but none seemed to give me exactly what I wanted, so here I present yet another way of doing assembly versioning with Team Build 2010. I wanted my Team Build number to exactly match that of my assembly versions (and not be derived), like this:

So here’s how I do it. To start off with I customise the BuildNumber format within my build definition:

In my case, I decided to customise it so that the Major and Minor version numbers “0.1” were added explicitly. This lets me control the first two parts of the version number which is what I want to achieve. I also added the macros $(Month)$(DayOfMonth) with a 1 in front of it. For the 2nd May 2010 this would generate a number 10502. (The reason I don’t use the full year here is that for today it would generate a build number of 100502 and a file version number cannot be higher than 65335).
When I decide to work on version 0.2, 0.3 or 1.0 all I have to do is increment the Build Number here and save the definition, I’m also happy to increment the number when the year changes. I said it was simple!
The final part of the build number format was left as-is (i.e. the Revision number that increments by 1 with each build on that day and resets for the next day).
Now all we need to do is retrieve this version number when MSBuild is run against the solution, split the version number and take the numeric portion into the Properties\AssemblyVersion.cs file (you will need to comment out the AssemblyFileVersion line in that file first and check it in).
Here’s the fragment that you’ll need to insert in your .csproj file (you’ll have to check it out then open it in Notepad or your favourite text editor).
<UsingTask
TaskName="Microsoft.TeamFoundation.Build.Tasks.GetBuildProperties"
AssemblyFile="$(MSBuildProgramFiles32)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
Condition="' $(BuildUri) '!=' '"/>
<Target Name="BeforeBuild" Condition="' $(BuildUri) '!=' '">
<GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)">
<Output TaskParameter="BuildNumber" PropertyName="BuildNumber" />
</GetBuildProperties>
<PropertyGroup>
<BuildNumberSplitLocation>$([MSBuild]::Add($(BuildNumber.LastIndexOf('_')),1))</BuildNumberSplitLocation>
</PropertyGroup>
<ItemGroup>
<AssemblyVersionLines Include="[assembly:AssemblyFileVersion("$(BuildNumber.Substring($(BuildNumberSplitLocation)))")]" />
</ItemGroup>
<Exec Command="attrib -r "$(ProjectDir)\Properties\AssemblyInfo.cs"" ContinueOnError="false" />
<Message Text="Lines being added: @(AssemblyVersionLines)" Importance="high" />
<WriteLinesToFile File="$(ProjectDir)\Properties\AssemblyInfo.cs" Lines="@(AssemblyVersionLines)" />
</Target>
Posted by Stuart Preston on April 13, 2010 under Team Foundation Server |
Hopefully this will save someone a minute or two.
In Visual Studio 2010 to enable Code Coverage, you edit the .TestSettings file (e.g. Local.TestSettings) – similar to the TestRunConfig file in Visual Studio 2008. Code Coverage no longer has its own section – it can be found under Data and Diagnostics where you can then set Code Coverage to enabled by checking the box.

The subtle thing I missed for a couple of minutes was that the Configure button at the top of the grid only is enabled when you select the Code Coverage row – and in there is the Code Coverage Detail dialog that lets you select the “artifacts to instrument”.
Looks pretty obvious now huh!
Posted by Stuart Preston on February 14, 2010 under ALM, Application Lifecycle Management, SDLC, Software Development Lifecycle, Team Foundation Server, UKALMUG |
The inaugural meeting of the UK ALM User Group was held on Thursday 11th February at Microsoft’s Cardinal Place offices near Victoria in London.
The session was deliberately left with an open agenda, and after we had made our introductions we shared many anecdotes from our collective experiences with ALM, the discussion on the day mainly focusing around people and process rather than the tools.
As the majority of people in the meeting were practitioners using Microsoft ALM tooling – there was widespread support for bringing in presenters on non-Microsoft ALM tools to ensure that the group kept abreast of the latest developments.
Some of the wider questions about the group included:
– What is the vehicle for the UK ALM User Group message?
– Should the UK ALM User Group have a “voice”?
– How do we spread the word about ALM and ‘make it stick’.
Lessons learned were that we need to prioritise the topics and also timebox them! Hopefully in future sessions this will be easier to achieve.
It was agreed that each member of the group should try and post a session topic to the User Group website (http://ukalmug.ning.com/forum/topics/discussion-topics-for-uk-alm). The most popular session topics will be determined and we can then find presenters for them.
There was also broad support for having the UK ALM User Group more regularly than the initially proposed (quarterly). More details on this will follow soon. If anyone can recommend a bar or other venue in London with presentation facilities then please let me know.
Drinks, socialising and continuation of some of the discussions were then had at a local bar…
Thanks to Microsoft for providing the venue and for the enthusiastic attendees some of whom had travelled from out of London to come to the meeting. Hope to see all of you and more at the next meeting.
Please remember to tag anything related to the user group on twitter with #ukalmug. There is also a list of members on twitter at @ukalmug/members
Posted by Stuart Preston on November 9, 2009 under Team Foundation Server |
I recently responded to a question on a Microsoft discussion list. The question was (paraphrased):
I need to get the clock value assigned to “Field B” when the value of “Field A” is changed to a specific value. Field A allows Yes, No values only.
I need the exact time “Field A” gets assigned Yes. When it goes back to No, I must not do anything with the value stored in “Field B”. Then if “Field A” gets assigned Yes one more time, I need “Field B” updated with the DateTime of when this assignment happened and not losing the value until next time field A gets triggered to Yes.
Well I remembered doing something similar during some prototyping on Scrum for Team System. The initial trap is that when you set up a <COPY from=”clock” /> rule on a TFS WIT field, then Team Explorer refreshed this time after the work item is saved. This is not the behaviour we wanted to see. After a bit of experimentation, success!
<FIELD name="FieldA" refname="Playground.FieldA" type="String">
<COPY from="value" value="No" />
<ALLOWEDVALUES>
<LISTITEM value="Yes" />
<LISTITEM value="No" />
</ALLOWEDVALUES>
</FIELD>
<FIELD name="FieldB" refname="Playground.FieldB" type="DateTime">
<WHEN field="Playground.FieldA" value="Yes">
<COPY from="clock" />
</WHEN>
<WHEN field="Playground.FieldA" value="No">
<READONLY />
</WHEN>
</FIELD>
As you can see, the trick is to deliberately set FieldB to <READONLY /> when FieldA is “No”. I thought I’d post this here in case anyone else needs to do something similar. A view of the history on the Work Item I edited confirms the modification works as required:
![clip_image002[6] clip_image002[6]](http://stuartpreston.net/blog/wp-content/uploads/2009/11/clip_image0026_thumb.jpg)
This sample should work on TFS2005, 2008 and all versions of 2010.
Posted by Stuart Preston on November 7, 2009 under Team Foundation Server |
I thought I’d post some utility code that I’ve been playing with to retrieve information about the Process Templates available on a TFS 2010 instance.
As you can see from the code, each TeamProjectCollection has its own store of Process Templates (in TFS 2008 there was in effect a single “Project Collection”) so we need to look through each collection to retrieve the templates that have been uploaded to it.
You’ll need references to Microsoft.TeamFoundation.dll, Microsoft.TeamFoundation.Client.dll, Microsoft.TeamFoundation.Common.dll. On a machine with Visual Studio 2010 installed they should be found in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0 or C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0 depending on whether you have a 64-bit version of Windows or not. You’ll also need to set the Target Framework to .NET Framework 3.5 as the assemblies required are in the v2 GAC.
This code will work against TFS2010 Beta 2 but is not guaranteed to work in the RTM.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.TeamFoundation.Framework.Client;
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Server;
namespace TFSUtils
{
class Program
{
static void Main(string[] args)
{
//replace this with the URL to your TFS instance.
Uri tfsUri = new Uri("http://sptfs02:8080/tfs");
TeamFoundationApplicationInstance tfai = new TeamFoundationApplicationInstance(tfsUri, new UICredentialsProvider());
tfai.EnsureAuthenticated();
ITeamProjectCollectionService collectionService = tfai.GetService<ITeamProjectCollectionService>();
IList<TeamProjectCollection> collections = collectionService.GetCollections();
foreach (TeamProjectCollection collection in collections)
{
if (collection.State == TeamFoundationServiceHostStatus.Started)
{
Console.WriteLine(String.Format("\nCollection: {0}", collection.Name));
IProcessTemplates processTemplates = tfai.GetTeamFoundationServer(collection.Id).GetService<IProcessTemplates>();
TemplateHeader[] templateHeaders = processTemplates.TemplateHeaders();
foreach (TemplateHeader header in templateHeaders)
{
Console.WriteLine(String.Format("\t{0} {1}", header.TemplateId, header.Name));
}
}
}
Console.WriteLine("\nPress any key to continue.");
Console.ReadKey();
}
}
}
Posted by Stuart Preston on October 23, 2009 under Team Foundation Server |
I will be presenting at Microsoft PDC 2009 along with Simon Bennett from EMC Consulting on Scrum for Microsoft Visual Studio Team System.
It will be very weird presenting with an ex-colleague and seeing a few folk I used to work with, but I’m looking forward to it and meeting all sorts of interesting people with stories to tell about their experience with the Scrum for Team System process template (I worked on this since the first Beta of Team Foundation Server 2005 right up to when I left EMC last month).
We’re going to do a drill down into the new features that have been implemented in the latest version that is compatible with Visual Studio 2010 Team Foundation Server Beta 2, and share our experience of extending Team Foundation Server.
Look forward to seeing some of you there!
PS: There’s still a $300 discount if you register before the end of October.
Posted by Stuart Preston on October 13, 2009 under Personal, Team Foundation Server |
Welcome to my new home on the web. I’ve been blogging for over 5 years at http://consultingblogs.emc.com/stuartpreston and will aim to continue here and keep those permalinks permanent.
I’m sure the range of topics on here will vary but for now will mostly be around Team Foundation Server, Application Lifecycle Management and life as an ex-CTO :) Yes as it’s my own blog I’ll be mixing some of my personal observations on life in with the work stuff too…
If you followed me here from my last blog at EMC Consulting and just want the new feed address, it is: http://stuartpreston.net/blog/?feed=rss2