I have a solution with multiple projects. All of these projects build just fine locally. When I try and build them using my TFS build server, one project throws an error:
C:\Builds\24\Folder\SolutionName\Sources\Folder\ProjectName.csproj (0, 0) Unhandled exception (4.1.13.0, postsharp.4.0-x64.exe, CLR 4.0.30319.394256, Release): PostSharp.Sdk.CodeModel.BindingException: Error while loading the type "UndoRedo.UndoableAttribute, The.NameSpace.Of.The.Project, Version=5.5.0.0, Culture=neutral, PublicKeyToken=c91567af84d23347": System.IO.FileLoadException: Could not load file or assembly 'PostSharp, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The problem is I have no idea why it is trying to reference version 2.1.0.0 because the project uses version 4.1.13 of PostSharp.
I have used agent Ransack to search for anything using v2.1.0.0 and nothing shows up. I've checked my project and it is seriously using v4.1.13 (Via NuGet).
Any hints or an answer would be most welcome, thank you.
EDIT: The build works when x86 or x64 is set. The error is thrown with AnyCPU configuration set.
Problem was the build output was already a reference registered to the GAC.