27

My VS2010 solution has a test project in it. The unit tests themselves reference the following namespace:

using Microsoft.VisualStudio.TestTools.UnitTesting;

which is accessed via the following assembly on my PC:

Assembly Microsoft.VisualStudio.QualityTools.UnitTestFramework
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\
    PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

When I build the solution on my PC I have no issues; the tests will build and run okay.

We have an intranet page which we can use to kick off builds on a build server. When I build via this page, the build fails with the following errors:

Generator.cs(3,17): error CS0234: The type or namespace name 'VisualStudio' 
does not exist in the namespace 'Microsoft' (are you missing an assembly
reference?)

The obvious problem would be that the Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll mentioned above is not present on the build server. I thought this was would be installed with VS2010, and since the projects in my solution build .NET 4.0 targets, I would expect this to be installed on the build server.

What is the easiest way to resolve this? The build server is out of my jurisdiction and I don't particular want to log a job to get new libraries installed on to it.

LeopardSkinPillBoxHat
  • 28,915
  • 15
  • 75
  • 111

2 Answers2

25

The .UnitTestFramework.dll sits in C:\Program Files... folder and you have a reference to it.

  1. Create directory under your source control eg. Source/Binaries
  2. Copy the said dll into Source/Binaries
  3. Remove the reference to .UnitTestFramework.dll from your unit test assembly
  4. Add the reference to .UnitTestFramework.dll to your unit test assembly but this time select the dll that is now under Source/Binaries

After that you can checkin your changes (make sure the Source/Binaries folder is checked in) and build the solution. When build server builds the solution it should get the dll from the source control.

Toni Parviainen
  • 2,217
  • 1
  • 16
  • 15
  • 1
    Wouldn't there be licensing issues with those dlls when you e.g. have your project as an open source project on e.g. Github? – Torben Koch Pløen Aug 24 '14 at 08:18
  • 8
    Just to answer my own comment: Yes, there will be licensing issues - this would not be allowed: http://social.msdn.microsoft.com/Forums/vstudio/en-US/32384366-b668-4f18-99eb-9c67f7eef233/redistributing-microsoftvisualstudioqualitytoolsunittestframeworkdll – Torben Koch Pløen Aug 26 '14 at 08:07
  • 1
    I did what the answer suggests. it works for my development PC (with VS) and our CI server (without VS). I would rather have the DLL pulled by NuGet, but I can't get that to work. – Robert Bratton Jun 17 '15 at 19:38
13

The specific answer for me and a Visual Studio 2010 solution was:

  1. Install "Test Agent 2010" from Visual Studio Agents 2010
  2. Restart Windows
  3. Install Visual Studio 2010 Service Pack 1
  4. Restart Windows
  5. Ensure the projects References are updated to point at "Microsoft.VisualStudio.QualityTools.UnitTestFramework" "10.1.0.0" and not "10.0.0.0".
Dean Taylor
  • 40,514
  • 3
  • 31
  • 50
  • 2
    Note that Visual Studio Agents 2015 installs framework 4.6.1 if your server doesn't already have it – Hoppe Apr 13 '16 at 14:56
  • 1
    To save someone else some time, the current version of the agents can be downloaded from https://www.visualstudio.com/downloads/?q=agents – James Skemp May 13 '18 at 19:45