An evening with TFS2012, Windows Server 2012 and Forefront TMG

Posted by Stuart Preston on September 8, 2012 under ALM, Application Lifecycle Management, Team Foundation Server, Visual Studio | Be the First to Comment

Have been busy installing an internal version of Team Foundation Server 2012, hosted on Windows Server 2012 using Forefront Threat Management Gateway 2010 to perform SSL operations and helping to ensure I don’t need to put my TFS server directly on the Internet.

As usual there were a couple of gotchas with this configuration so if there’s any interest in this configuration, I’ll find some time to write up my notes…

Automated installation of SQL Server 2012 for TFS “11″ at the command line

Posted by Stuart Preston on April 6, 2012 under ALM, Application Lifecycle Management, Team Foundation Server, Visual Studio | 2 Comments to Read

If I had one pound sterling for every Team Foundation Server install I’ve performed in my life I’d be a rich man by now. Back in late 2004/early 2005 when a number of us were playing with the alpha TFS 2005 bits, all the components had to be installed on a separate machines and if you made the slightest mistake it was a rebuild job from the bare metal – of course Virtualisation technologies like snapshotting weren’t mainstream in those days and installation was a pain!

Fast forward 8 years and here we are; .NET Framework is properly integrated as a system component in the OS, Virtualisation and snapshotting is the norm, disks have got much faster, TFS installs in minutes (not hours) and automatically configures IIS and all the prerequisites it needs, which makes life amazingly easy.

Grant Holliday wrote this article that I still refer to when I need to build a TFS2010 virtual machine from scratch so when I came to installing a brand new Windows 8 Server with SQL Server 2012 and TFS “11″ in a Virtual Machine I had to do a little bit of thinking for myself.

Assuming you want to create a Default instance of SQL Server 2012 complete with Analysis Services and SQL Server Reporting Services (SSRS) as if you had accepted all the defaults:

  • start with a completely blank Windows 8 Server image with no roles or features added
  • mount the disk in your favourite manner (i.e. mount the .iso image on your host machine from the menu on your guest VM, or use Virtual CloneDrive to mount the .iso file locally)
  • at a new administrator command prompt, replace the highlighted bits with a valid user who you wish to have full access to everything!) and paste the whole thing:
d:\setup.exe /QS /ACTION="Install" /ENU /UpdateEnabled /FEATURES=SQLENGINE,FULLTEXT,AS,RS,SSMS,ADV_SSMS /UpdateSource="MU" /INDICATEPROGRESS="True" /X86="False" /INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server" /INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server" /INSTANCENAME="MSSQLSERVER" /INSTANCEID="MSSQLSERVER" /SQMREPORTING="False" /RSINSTALLMODE="DefaultNativeMode" /ERRORREPORTING="False" /INSTANCEDIR="C:\Program Files\Microsoft SQL Server" /AGTSVCACCOUNT="NT Service\SQLSERVERAGENT" /AGTSVCSTARTUPTYPE="Manual" /ASSVCACCOUNT="NT Service\MSSQLServerOLAPService" /ASSVCSTARTUPTYPE="Automatic" /ASCOLLATION="Latin1_General_CI_AS" /ASDATADIR="C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Data" /ASLOGDIR="C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Log" /ASBACKUPDIR="C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Backup" /ASTEMPDIR="C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Temp" /ASCONFIGDIR="C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Config" /ASPROVIDERMSOLAP="1" /ASSYSADMINACCOUNTS="VS11BETA\Administrator" /ASSERVERMODE="MULTIDIMENSIONAL" /SQLSVCSTARTUPTYPE="Automatic" /FILESTREAMLEVEL="0" /SQLCOLLATION="Latin1_General_CI_AS" /SQLSVCACCOUNT="NT Service\MSSQLSERVER" /SQLSYSADMINACCOUNTS="VS11BETA\Administrator" /TCPENABLED="1" /NPENABLED="0" /BROWSERSVCSTARTUPTYPE="Disabled" /RSSVCACCOUNT="NT Service\ReportServer" /RSSVCSTARTUPTYPE="Automatic" /FTSVCACCOUNT="NT Service\MSSQLFDLauncher" /IAcceptSQLServerLicenseTerms

Installation will progress for a while but when finished you have all the components required to do the TFS 11 install immediately afterwards.

Simple assembly versioning with Team Build 2010

Posted by Stuart Preston on May 2, 2010 under Team Foundation Server | 5 Comments to Read

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:

image

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

image

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(&quot;$(BuildNumber.Substring($(BuildNumberSplitLocation)))&quot;)]" />
  </ItemGroup>

  <Exec Command="attrib -r &quot;$(ProjectDir)\Properties\AssemblyInfo.cs&quot;" ContinueOnError="false" />
  <Message Text="Lines being added: @(AssemblyVersionLines)" Importance="high" />
  <WriteLinesToFile File="$(ProjectDir)\Properties\AssemblyInfo.cs" Lines="@(AssemblyVersionLines)" />
</Target>

Enabling Code Coverage in Visual Studio 2010

Posted by Stuart Preston on April 13, 2010 under Team Foundation Server | 4 Comments to Read

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.

image

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!

Report: 1st UK ALM User Group meeting

Posted by Stuart Preston on February 14, 2010 under ALM, Application Lifecycle Management, SDLC, Software Development Lifecycle, Team Foundation Server, UKALMUG | Read the First Comment

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

TFS WIT hacks: Setting a DateTime field based on String value in another field

Posted by Stuart Preston on November 9, 2009 under Team Foundation Server | Be the First to Comment

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]

This sample should work on TFS2005, 2008 and all versions of 2010.

TFS2010 API: Retrieving a list of Process Templates on the server.

Posted by Stuart Preston on November 7, 2009 under Team Foundation Server | 2 Comments to Read

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();
        }
    }
}

See you at PDC 2009?

Posted by Stuart Preston on October 23, 2009 under Team Foundation Server | Be the First to Comment

imageI 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.

New blog site

Posted by Stuart Preston on October 13, 2009 under Personal, Team Foundation Server | 2 Comments to Read

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