Monday, October 27, 2014

MSB3268 while targeting ASP.NET web site project to framework 4.5

Just spent 2 days with trying to understand why on Earth my ASP.NET web site project stopped compiling when I re-targeted it to framework 4.5.

My dependent projects were all re-compiled under framework 4.5 without any issue.

Visual Studio 2012 compiled the web site without any issue either.

While the build server, working under Jenkins had its MSBuild job failing with MSB3268 warnings saying that the System.Threading.Tasks and System.Runtime assemblies could not be found under the framework version of "v4.5".

A deeper inspection revealed the following interesting fact: aspnet_compiler for some reason does not take into account the .dll-s that reside under the Facade directory of 4.5 assemblies (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades).
It looks only under
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5

As a result the whole thing failed since both System.Threading.Tasks and System.Runtime .dll-s were under the Facades directory and not inside the v4.5.


Now the solutions:

  1. Just simply copy the missing .dll-s from Facade to the v4.5 directory.
  2. Set the TargetFrameworkMoniker to 4.5.1 in the .sln file. The exact syntax is as follows: TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.5.1".
          What happens in this case is that the aspnet_compiler does not recognize the exact version of the required framework and tries to use the GAC wherever it can. If 4.5 is the highest version installed on the build machine I believe it should work.

Very tiring.