On the build machine, there is a file called Microsoft.TeamFoundation.Build.targets, usually found in C:\Program Files\MSBuild\Microsoft\VisualStudio\v8.0\TeamBuild.
In this Team Build targets file, you can find the following line:
<VSINSTALLDIR Condition=" '$(VSINSTALLDIR)'=='' and '$(NetSamplePath)'!=''" >$(NetSamplePath)\..\..</VSINSTALLDIR>
The purpose of the line is to help find the code analysis assemblies on the build machine. Somehow it looks like your NetSamplePath is a space or something else that is not empty, but looks empty. So, vsinstalldir gets set to a completely invalid path. It's hard to say what's really happening. But I definitely think you need to set that variable for now. You might want to try using the following property that we pass in to MSBuild on the command line:
/p:TeamBuildRefPath="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies" |