A search on this topic yields many answers for all the different possible combinations of Visual Studio web projects. Here is another.
Using .Net 3.5 MSBuild.exe take note of the following targets and the custom parameter, WebProjectOutputDir, passed when attempting to publish a web application project.
- /t:ResolveReferences;_WPPCopyWebApplication
- /p:WebProjectOutputDir=”c:\\Source\\Build\\My Web App\\” – this is the path to the output directory, all ‘\’ must be replaced with ‘\\’
A complete call will look something like this:
msbuild.exe MyWebApplication.csproj /p:Configuration=Release /t:ResolveReferences;_WPPCopyWebApplication /p:WebProjectOutputDir=”c:\Source\Build\My Web App”