Wednesday, September 23, 2015

Microsoft Fakes issue after upgrading to TFS 2015

After upgrading to Team Foundation Server 2015, some of our builds started to fail.

Inside the build log, I found a long list of errors. All similar to the following:

f.cs (17985, 0)

The type or namespace name 'EventIgnoreAttribute' does not exist in the namespace 'System.Diagnostics.Tracing' (are you missing an assembly reference?) [c:\b\1\App\Daily Release\Sources\App\Test\Test.Mailing\obj\Release\Fakes\m\f.csproj]

This test project is using the Microsoft Fakes framework to mock the usage of the SmtpClient. But for an unknown reason the fakes framework cannot generate code for some of the namespaces inside the System DLL. I found some forum posts where people had similar issues.

I couldn’t find a real solution, but I was able to fix the issue by applying the following workaround:

  • Inside Visual Studio open the project where you are using the Fakes framework
  • Go to the Fakes folder inside this project
  • For each fakes file, clear the existing stub and shim generation.
  • Explicitly add the types you need

An example:

No comments: