I have found a solution to the problem, which turns out to be a pretty simple one. The default Configuration in TFS Build look like this: Configuration: Release, Platform: Any CPU
But in Visual Studio 2012 it looks like this: Configuration: Release, Platform: AnyCPU
The solution is to remove the space between Any and CPU in the TFS Build Platform. Now it works perfectly.