Local build works fine. One build server works fine (which isn’t using a TFS Build).
The problem is that a TFS build packages the MVC3 binary, not the MVC4 required.
SERVER 1: Our TFS server has only MVC4 installed (though I don’t believe this is needed anyway).
SERVER 2: Our TFS build controller has only MVC4 installed. (The build agents are on the same server).
Note: both SERVER 1 and 2 have had MVC3 installed previously.
I queue a new build, go to SERVER 2 (build controller server) and I see the agent is working (TFS Admin Console) and has created its working directory.
However the working directory eventually contains the MVC3 binary! This is then dropped in the drop location on a hosting server, which is then deployed incorrectly with MVC3.
An MSBuild from the command line on ‘SERVER 2’ also adds the MVC3 Binary to the bin folder. The GAC contains the MVC4 binary. (C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_4.0.0.0__31bf3856ad364e35)
The web.config of the project in question correctly references MVC4, and System.Web.Mvc (v4.0.0.0) is set to copy local. I have checked for MVC3 references extensively. I have no reason to doubt the code, as this works on our legacy build server (which has MVC4 installed).
And of course it all works on my machine, a publish contains the correct MVC.dll in the bin folder.
Where could it possibly be getting MVC3 from? What could I be missing?
SHORT TERM FIX: Install MVC4 on hosting server.
Finally solved this, there is a Reference Assemblies folder inside of program files that contained
system.web.mvc.dll(version 3). I deleted it, and it everything works!Simply put: “.NET version 4.0 made a big change in the way framework reference assemblies are done.”
The answer in this question gives more details as to what this folder is and why it is there: Reference Assemblies folder and different assemblies with the same version.