Yesterday, I installed VS 2012 side by side with VS 2010 and after recompiling and deploying a web project, it failed with the same exception. After an hour of research, I found a solution.
First you need to edit nant.exe.config
Open it and find:
<framework name="net-4.0"
Its OK. on line 555 (in the default configuration for NAnt 0.92)
You will see a huge xml describing the compilation of net-4.0. Find the three children of the <reference-assemblies> . The first two look like
<reference-assemblies basedir="${path::combine(installRoot, 'v4.0.30319')}"> <reference-assemblies basedir="${path::combine(installRoot, 'v4.0.30319')}/WPF">
and the third -
<reference-assemblies basedir="${environment::get-folder-path('ProgramFiles')}/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0">
And now - just edit the first two to fit the third (copy from the third and paste-replace the 1st and 2nd). After that, NAnt will look for all the DLL files in the Reference Assemblies folder (instead, Windows / Microsoft.NET / ... is "broken")
Do not worry about the /WPF suffix in the second - in Reference Assemblies all files are in the same folder without the / WPF subfolder.
Second step - change your build script
When invoking the csc task csc add two attributes nostdlib and noconfig :
<csc target="..." output="..." nostdlib="true" noconfig="true" ...>
This will disable the automatic binding of the bad new mscorlib and other librares from the csc folder.
And inside the <references> element - manually add mscorlib.dll, system.core.dll and all used system libraries. NAnt will find them in the Referenced Assemblies folder:
<references> <include name="mscorlib.dll"/> <include name="Microsoft.CSharp.dll"/> <include name="System.dll"/> <include name="System.Configuration.dll"/> <include name="System.Core.dll"/> ...
After this (and, of course, rebuilding), my site was successfully launched on the hosting machine with the "original" .NET Framework 4. :)
PS It looks like Microsoft has reinvented the DLL HELL :)