Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 found (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.

like image 790
Asif Avatar asked Aug 03 '11 15:08

Asif


People also ask

Where does MSBuild build to?

With Visual Studio 2019 and later, it's installed under the Visual Studio installation folder. For a typical default installation on Windows 10, MSBuild.exe is under the installation folder in MSBuild\Current\Bin.

Is it is possible to build application if MSBuild is not installed?

Is it possible to build an application on a system if the MSBuild is not installed? If so, How? Yes, it is actually possible because the MSBuild doesn't depend on the Visual Studio of its operations. Users simply need to install the msbuild.exe file for this.

How do I run MSBuild locally?

To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.


2 Answers

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.

like image 154
Cyrus Avatar answered Oct 15 '22 20:10

Cyrus


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

like image 22
Junior Mayhé Avatar answered Oct 15 '22 19:10

Junior Mayhé