psake, .NET 4.5.2 and MSBuild

Back to blog

At the time of writing (December 2014), the latest version of psake (4.4) defaults to the .NET framework 4 if you don’t explicitly set a framework at the top of your build scripts.

Due to the the peculiar way Microsoft setup MSBuild for .net 4.5.x, this means that psake fails with the following error if you try to build a solution that targets 4.5.1 or 4.5.2.

You have to explicitly set the ‘Framework’ variable to 4.5.1 at the top of the file to make psake use the correct version of msbuild.

Note that using the value 4.5.1 also works for projects that target 4.5.2 (the value 4.5.2 is not recognised by psake).