How to invoke MSBuild via command prompt?
From your comment, your web project is a web site project and not a web application project.
In this case, 'Publish' target can not be the option but 'AspNetCompiler' is the solution.
Create an xml file with below content and call it from MSBuild.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PrecompileWeb">
<AspNetCompiler
VirtualPath="/MyWebSite"
PhysicalPath="c:\inetpub\wwwroot\MyWebSite\"
TargetPath="c:\precompiledweb\MyWebSite\"
Force="true"
Debug="true"
FixedNames="True"
/>
</Target>
</Project>
Reference to this task is here and you can configure all your un/check options.
FixedName="True" equals the checking of 'use fixed naming and single page...' option.
Then you call this file from MSBuild instead of the solution file.
MSBuild your.xml /p:Configuration=<Debug/Release>
As long as your class libraries are referenced by your web site project, they'll be built together.
MSBuild.exe **MYPROJ**.sln
/p:outdir="Z:\output\\",OutputPath="Z:\output\\",webprojectoutputdir="Z:\output\\",configuration=RELEASE
/t:Clean;Build
/flp1:logfile=Z:\output\\\Log_msbuild.log;verbosity=detailed
/flp2:logfile=Z:\output\\\Log_warnings.log;warningsonly;verbosity=detailed
/flp3:logfile=Z:\output\\\Log_errors.log;errorsonly;verbosity=detailed
/nologo
/noconlog
İt can compile all Types of projects(Web,webservice,desktop,..) and it can create log files as(buildlog,error and warnings).