I have a solution which uses Solution Folders to split out the projects. In the Visual Studio IDE, the solution builds fine.
However when running the build using MSB
I faced the same issue and managed to sort out:
Cheers, hope this can help anyone