6

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!!!

user2799559
  • 61
  • 1
  • 3
  • The error doesnt specify that it didnt create the fakes assembly it says it cannot locate it this is not one one the same. Im not familiar with how Microsoft Fakes works, however it should generaly have a call inside project file as an msbuild target or pre/post build command/tool. TFS builds override the default output folder, it may be as simple as it not supporting the override and getting created along the sources. Find from where and how the fakes creation is called that should allow you to discern what happens. – drk Sep 23 '13 at 10:10
  • I've been spending more time looking at this. It appears that the build is not using the MSBuild that ships with VS2013. It appears to be using the one that goes with Team Build 2012. There used to be a way in the TFSBuildServiceHost.exe.config to specify which MSBuild to use (at least back in TFS 2010), but that appears to not work anymore - as I tried to point it to the VS2013 MSBuild, and it continued to use the Team Build 2012 installed MSBuild. When I use the VS2013 MSBuild from command prompt - it works. When I use the Team Build MSBuild from the command prompt - I get the above err – user2799559 Sep 23 '13 at 11:58
  • The ToolPath property might be worth to check out http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.build.workflow.activities.msbuild.aspx If that doesnt work you might need to write your own msbuild wrapper activity if you cant find and override, going by following the way msbuild is loaded might have changed since its not part of .net framework anymore http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx. – drk Sep 27 '13 at 10:07

1 Answers1

2

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

Alex
  • 211
  • 2
  • 12