We have a seemingly common mistake
Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
in a project that needs to be compiled with .Net 4.0, but built on a build server running Windows Server 2012 (with .Net 4.5). The project is a web application that is deployed to a web server running 2003, where installing .Net 4.5 is not an option. There he works against the "classic" .Net 4.0
From similar questions, we are trying to use command line options for MSBuild:
/property:FrameworkPathOverride="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
We also tried various combinations
/property:ReferencePath="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
/property:NoStdLib=true
/property:NoCompilerStandardLib=true
Reference assemblies (including DLL files) are actually installed at this location on the assembly server. But when we deploy the website and visit the homepage, we get this error. (It is interesting that when the page reloads, the error disappears and the site works fine.) What are the MSBuild parameters required to compile with .NET 4.0 assemblies?
Update
I turned on ludicro-level logging on MSBuild, and I can see that it seems to be building against .Net 4.0 link collections:
Resolved file path is "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll
and I did not see the mention of assemblies outside this folder or the working directory of the assembly server. Therefore, it seems to compile correctly, but when deployed to a web server, it throws an exception.
, , , . aspnet_compile . , , - . , .Net 4.0.