Tuesday, 27 October 2009

TFS 2010 Beta 2 unit testing automated builds

I’ve been setting up Team Foundation System 2010 Beta 2 at work over the past couple of days. First starting off with doing it on a virtual machine locally to do some testing, but then deploying it into the virtual server environment we’ll be using it in for every day development.

I was initially very impressed by the ease of setup of the system. Talking to people and ready some blogs about setting up previous versions of TFS it was a complete pain with caused serious issues with server setup, permissions etc. TFS 2010 is soooo simple in comparison. Microsoft have thought about this side of things a lot and made setting it up very simple.

We went for the basic setup as we don’t need a lot of power or more than source control, automated builds and work item tracking.

Anyway, setup of the machine was fine and enabling communication between the tfs server and my laptop running Visual Studio 2008 sp1 was fine (just needing to make sure that Team Explorer is installed, followed by running the VS SP1 setup again, then the forward compatibility patch) and the first solution of code was checked in. A small utility dll project and associated unit test project. As the plan is to use this utility in all future development, a “tool kit” as you would, it made sense that this should be setup to have an automated build. It would also enable me to learn how to setup automated builds.

Enter first issue, no reference issues relating to “Microsoft.VisualStudio.QualityTools.UnitTestFramwork.dll”. Due to this issue the test project could not build as it had references to a namespace it couldn’t find.

C:\Windows\Microsoft.NET\Framework64\v3.5\Microsoft.Common.targets: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

To resolve this initially I installed the C# components of Visual Studio 2010 Beta 2 on the server. I had originally just done the unit testing parts but this didn’t resolve the issue. The obvious issue with this is that we don’t want to have the full version (or any part of) Visual Studio installed on the server so I did this on a VM locally to see if resolved the issue … it didn’t :-(

Break through

After doing some more search on Google, I found this post from Grumpy Wookie about the location of the gacutil in the SDK, and another link (which I can’t seem to find in my history, sorry) relating to the fact that there aren’t the correct versions installed in the GAC on the server. So after checking the versions and seeing there weren’t any there …

I copied the following dll from my dev machine (with VS2008 on):



C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5

I then opened a cmd prompt on the server and navigated to where the SDK resides and ran the following cmd:

C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin>gacutil.exe /i "C:\Program File
s (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\Microsoft.Visua

This loaded version 9 of the UnitTestFramework into the GAC. This allowed for the automated build to run and to run the unit tests in my solution. Only issue now is the fact that it seems to be running with v10 MSBuild/MSTest with the v9 unit test assemblies and because of that it doesn’t like the one test which is using the ExpectedExceptionAttribute. At the moment I can live without this test being run on the server … but roll on march when the full version of TFS/VS 2010 come out and I can upgrade my development environment.

Hope this helps.

No comments: