AFAIK, VS uses the same implementation of the MSBuild engine but has some sleazy (buggy) performance optimizations. Add the property DISABLEFASTUPTODATECHECK=1 to get the same behavior.
We found this allowed us to eliminate differences we saw and found hard to track down and infuriating:
https://msdn.microsoft.com/en-us/library/vstudio/ms171468%28...