So, I have VS 2010 installed and am in the process of modifying my MSBuild script for our TeamCity build integration. Everything is working great with one exception.
Another answer to this topic after I've been searching for days before I tackled this issue:
Your publish profile and configuration names should match.
In my case mine didn't. Manually publishing through the publishing profile gave me the result I wanted, because my configuration was set in the publish profile. MSBuild however tries to be intelligent and magically connects the publish profile and configuration based on name. (Adding the /p:Configuration in the command resulted in other strange errors about the outputpath of a referenced project).
Just to be exactly clear in what I mean:
MSBuild statement from command line
msbuild myproject.csproj -t:Clean -t:Rebuild /p:DeployOnBuild=true /p:PublishProfile="Development"
WORKS
DOES NOT WORK
Hope this helps!