I had a very similar problem. I can start the publishing wizard in Visual Studio 2012 Pro and publish it normally, but when I start it with msbuild on the command line it will give an error "startIndex cannot be longer than the line length"
I found that this is because I called msbuild without specifying configuration mode. Once I determined the release configuration, it worked.
This is how I earned for my build script
MSBuild "MySolution.sln" /property:Configuration=Release /property:DeployOnBuild="true" /property:PublishProfile="MyPublishProfile"
Hope this helps.
Peter Flannery
source share