MS Build does not compile MS Test Project on the build server

I use TFS 2008 and VS 2010. After adding the MS Test project to my solution, I started getting the following errors on the build server.

UnitTest1.cs (5,40): error CS0234: the name of the type or namespace name "UnitTesting" does not exist in the namespace "Microsoft.VisualStudio.TestTools" (are you missing the assembly link?) UnitTest1.cs (22,17): error CS0246: type or namespace name "TestContext" not found (do you miss a directive or assembly reference?) UnitTest1.cs (28.16): error CS0246: Type or name namespace TestContext could not be found (you are missing a directive use or assembly reference?) UnitTest1.cs (62.10): error CS0246: type name or namespace name "TestMethod" not found (do you miss using directive or assembly reference?) UnitTest1.cs (62.1 0): error CS0246: type or namespace name 'TestMethodAttribute' not found (are you using a directive or assembly reference?) UnitTest1.cs (12.6): error CS0246: name or type namespace name "TestClass" was not found (do you miss the using directive or the assembly reference?) UnitTest1.cs (12.6): error CS0246: the type or namespace name 'TestClassAttribute' was not found (are you missing the using directive or assembly reference?) The task "Csc "- FAILED.

I installed VS 2010 on the build server, but still the same errors.

+7
source share
3 answers

The problem is in your test projects. You are referencing some assemblies that have not been deployed to the assembly server. Also you cannot do this, just copy and paste into the GAC or working directory.

The best way to do this is to install Visual Studio 2010 agents on the build server. It is free and can be downloaded from the MS website. After installing the agents, he will install all the necessary libraries for compiling and even starting MSTest projects.

+7
source

You can check if you are using the correct MSBuild. In my case, when I receive messages such as:

'TestMethod' could not be found 

We had to make sure that we have the correct version of MSBuild.

 C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe your_solution.sln /t:rebuild /t:Rebuild /clp:ErrorsOnly 

It also fixes some problems with Microsoft.VisualStudio.QualityTools.UnitTestFramework .dll

+2
source

Your tags mention VS2010 and TFS2008. By default, unit test projects have target .NET 4.0 installed, and Team Build 2008 will not know how to handle them. You must configure your test projects on .NET 3.5 (this can only be done if you installed VS2010 SP1). Or upgrade TFS 2008 to TFS2010.

If you want to run the testing tools with TFS 2008, you must also install Visual Studio Team Developer or Suite in the build agent. Visual Studio 2010 will not help you.

0
source

All Articles