I banged my head on this for a full 8 hours, gave up, and figured it out in 30 minutes the next morning. I have tried everything I could find on the interwebs. Here is how i figured it out. I already confirmed that i have sdk 7.1, 7.0 installed on my build agent. Ultimately it came back to registry settings.
First for MSBUILD Under "HKEY_LOCAL_MACHINE\SOFTWARE\MSBUILD\ToolsVersions\4.0". The Key SDK40toolsPath value is $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools-x86@InstallationFolder) on my build agent.
Which references "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools-x86@InstallationFolder". However, on my build agent that registry didn't exist! So it was referencing NOTHING. I don't know how the 7.0A registry setting are supposed to get there?!
So, I exported the entire "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" registry from a working build agent to a file then copied and imported it to the broken agent. It finally works now. Hope this helps someone.
This is probably over kill but here is the exported registry file contents.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
"ProductVersion"="7.1.7600.0.30514"
"ProductName"="Microsoft Windows SDK for Windows 7 (7.1.7600.0.30514)"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools]
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Tools for .NET Framework 4.0"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\NETFX 4.0 Tools\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools-x64]
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Tools for .NET Framework 4.0 (x64)"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\NETFX 4.0 Tools\\x64\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools-x86]
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Tools for .NET Framework 4.0"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\NETFX 4.0 Tools\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKBuild]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Microsoft Windows SDK Headers and Libraries"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKIntellisenseNFX]
"InstallationFolder"="C:\\Windows\\Microsoft.NET\\Framework\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Microsoft Windows SDK Intellisense for .Net"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKIntellisenseRefAssys]
"InstallationFolder"="C:\\Program Files\\Reference Assemblies\\Microsoft\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Intellisense and Reference Assemblies"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKInterop]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Microsoft Windows SDK NetFx Interop"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKNetFx35Tools]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Microsoft Windows SDK NetFx 3.5 Tools"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKNetFx35Tools\1033]
"SP"=dword:00000000
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKNetFx35Tools-x64]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\x64\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Microsoft Windows SDK NetFx 3.5 Tools (x64)"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKSamples]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Samples\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Samples"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKTools]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Common Utilities"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKTools-x64]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\x64\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Common Utilities (x64)"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKWin32Tools]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Utilities for Win32 Development"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKWin32Tools-x64]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\x64\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Utilities for Win32 Development (x64)"}