Ok I found a solution that works. You need to do two things:
- First add FrameworkPathOverride as a commandline parameter and point it to the references assemblies directory.
Something like
msbuild -p:FrameworkPathOverride="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
- The second thing you need to do is find a full version of the reference assemblies directory. Since the copy installed by the windows SDK and the one installed by visual studio, I just copied mine from my development machine. Works fine.
One final note: the reason this might have happened to me in the first place is that our build server is a nice old windows server 2003 one. Too old for the windows SDK install to cope with?