开发者

MS Build Not Compiling MS Test Project on Build Server

I am using TFS 2008 and VS 2010. After adding a MS Test project to my solution I started receiving following errors on the Build server.

UnitTest1.cs(5,40): error CS0234: The type or namespace name 'UnitTesting' does not exist in the namespace 'Microsoft.VisualStudio.TestTools' (are you missing an assembly reference?) UnitTest1.cs(22,17): error CS0246: The type or namespace name 'TestContext' could not be found (are you missing a using directive or an assembly reference?) UnitTest1.cs(28,16): error CS0246: The type or namespace name 'TestContext' could not be fo开发者_JAVA百科und (are you missing a using directive or an assembly reference?) UnitTest1.cs(62,10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) UnitTest1.cs(62,10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) UnitTest1.cs(12,6): error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?) UnitTest1.cs(12,6): error CS0246: The type or namespace name 'TestClassAttribute' could not be found (are you missing a using directive or an assembly reference?) Done executing task "Csc" -- FAILED.

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


The problem is in your test projects. you're referencing to some assemblies which haven't been deployed to the Build Server. Also you cannot do that by simply copy and paste to GAC or working directory.

The best and easiest way to do that is installing Visual studio 2010 Agents in the build server. It's free and it can be downloaded from MS web site. By installing the agents, it will install all the required libraries for compiling and even running the MSTest projects.


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

'TestMethod' could not be found

We had to be sure we are running correct MSBuild version.

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

That also fixes some issues with Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll


Your tags mention VS2010 and TFS2008. By default unit test projects are set to target .NET 4.0 and Team Build 2008 won't know how to handle those. You should set your test projects to target .NET 3.5 (can only be done if you've installed VS2010 SP1). Or upgrade TFS 2008 to TFS2010.

If you want to run the testing tools with TFS 2008, you should also install Visual Studio Team Developer or Suite on the build agent. Visual Studio 2010 won't help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜