Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS 2012 + VS 2013 + Microsoft Fakes compile issue (only during TFSBuild)

We are using TFS 2012 (Update 3) and VS 2013 RC. We have a .sln file with a two projects - the main project / assembly, and a UnitTest project. The unit test project is leveraging Microsoft Fakes. Within Visual Studio (we are using Premium), I can compile the .sln and run the tests. On the build agent, I can use Visual Studio to compile and build the .sln and run the tests. But when we queue a build, it fails to build the UnitTest project because it can't find the Fakes assembly. It doesn't appear to be dynamically creating it like it does when you build in Visual Studio. Typically in VS is creates the fakes dll and puts it in the FakeAssemblies folder. After the build fails, I can log in and see it did not create a FakeAssemblies directory at all.

The error is... C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (1605): Could not resolve this reference. Could not locate the assembly "System.Web.Http.5.0.0.0.Fakes". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

Our build is using the default template - and we have selected to build the .sln (which has the main assembly and the unit test project). Should we not be including the UnitTest in that .sln? Is there some other way the UnitTest should be getting compiled during the build?

Does anyone know why the build wouldn't by creating the Fake assembly dynamically like Visual Studio does?

Thanks!!!

like image 703
user2799559 Avatar asked Sep 20 '13 14:09

user2799559


1 Answers

I had the same issue but with TFS 2012 and VS 2012 and solved it by installing Visual Studio in TFS Server. So if you've already installed VS there, this advice won't help you.

First, I tried to copy that assembly from the folder in my local machine to the same folder in the TFS server. It's located in c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies\Microsoft.QualityTools.Testing.Fakes.dll.

The problem was solved, a test project was built successfully, but each test that were using Fakes were not passed. There was an exception:

Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test.

I did not have time and decided to make the second step and installed Visual Studio in TFS machine and all problems disappeared

like image 77
Alex Avatar answered Nov 06 '22 17:11

Alex