MS Fakes unit tests failing after Visual Studio 2013 Update 4

18.2k views Asked by At

I have recently upgrade from Microsoft Visual Studio 2013 Update 3 (Premium edition) to Microsoft Visual Studio 2013 Update 4 (Premium edition) and now my existing unit test projects have stopped compiling. It fails with the error:

The type 'Microsoft.QualityTools.Testing.Fakes.Stubs.StubBase`1' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

We, along with a lot of other people, had a similar issue where a bug was introduced in VS2013 that could be resolved by manually deleting the .messages file (via File Explorer or solution explorer with view all files enabled) inside FakesAssemblies folder inside the project folder. This however doesnt fix the issue, even if I delete the entire FakesAssemblies folder.

The reference to the project (including correct version is their within the project). I have deleted the reference and readded it and it has no effect, they still fail to compile.

The unit test projects still compile and pass on other colleagues machines with Visual Studio 2013 Update 3.

New projects unit test projects using MS fakes also fail to build.

So short of, uninstalling the Update 4 is there anything else I can try?

If not I'll log a bug on Microsoft Connect.

5

There are 5 answers

0
Kyle On BEST ANSWER
  1. the fix was to remove all references ending with .FAKES (including the Microsoft.QualityTools.Testing.Fakes.dll reference).
  2. I also removed the FAKES folder
  3. Cleaned solution
  4. Then readded all references back in.

We had some further errors to do with Shims but we just converted these to Stubs.

We had to upgrade all our projects this way manually, all VS instances including the build server.

1
The Chiller On

In the reference properties for Microsoft.QualityTools.Testing.Fakes, change "Specific Version" property to FALSE. Doing so will allow Visual Studio 2013 to use whatever version of Microsoft.QualityTools.Testing.Fakes is installed on your machine.

With Visual Studio 2013 Update 4, Microsoft incremented the version number of Microsoft.QualityTools.Testing.Fakes.dll from 11.0 to 12.0; this is what caused things to break.

1
DanielV On

After trying all answers here, It finally worked for me. The code:

using (ShimsContext.Create())

(used to) throw:

Failed to get address of function SetDetourProvider from library 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\vsperfcorprof.dll'.

My test project is running in 2012. I replaced the following dlls with these:

  • Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll (version: 10.1.0.00, file version: 11.0.60610.1)
  • Microsoft.QualityTools.Testing.Fakes.dll (version: 11.0.0.0, file version: 11.0.60315.1)

They were located in:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\

Hope it helps.

1
CloudCrusader On

Try to clean the whole project and compile it again, that worked for me!

0
RotatingWheel On

I added the followings assemblies and rebuilt my solution. It started to work for me. A. C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\Microsoft.QualityTools.Testing.Fakes.dll

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