November 2009 Entries
TFS Build Agent and MSBuild Running the VS 2005 version of MSTest when it should be VS 2008

 

One of our build servers is having trouble running one of our MSTest unit test assemblies, failing because it cannot parse the MSTest Test Run Config showing the error:

  Expected type attribute not found.

  File e:\teamserver\releasebuild\Assassin\Base SqlServer Continuous Integration\Sources\localtestrun.testrunconfig Line 2 Pos 2.

The log also shows that it is loading mstest from the VS2005 location.

The "TestToolsTask" task is using "MSTest.exe" from "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\MSTest.exe".

The build box has VS2005 installed and VS2008 and fail the build, the developers environment and a different build box only have VS 2008 installed and pass the build.

MSTest fails as our localtestrun.testrunconfig file uses the VS 2008 format and some of its features, so we have to run the VS 2008 version of MSTest .

It turns out that the reason the wrong (from our point of view) MSTest is running is that the unit test assembly has a reference to the VS2005 Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly, changing it to the VS 2008 reference causes the correct MSTest to be run.

The “testtoolstask” used to run tests within a TFS build inspects the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly reference to determine which version of MSTest to run.

Also, in Visual Studio the reference to the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly is shown pointing to VS2008 (version 9). Looking at the .csproj file of the unit test project directly, it references version 8; the VS2005 assembly.  I don’t have VS2005 installed so there must be some assembly version rebinding that happens so that  the VS2008 version 9 can be used for the VS 2005 version 8, hiding the issue.