Your solution and/or project files are set for one version of visual studio and MSBuild is building them as a different version. If you look in a solution file you're going to see something like this:
Microsoft Visual Studio Solution File,
Format Version 10.00
# Visual Studio 2008
The format version & visual studio # are going to vary based on whether you're using VS2003, VS2005, VS2008 and assumingly VS2010.
On your command line, where you're launching the build, it is launched from a specific version of the .NET framework:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild