title: How to Publish Web with msbuild?
body: <p>Visual Studio 2010 has a Publish command that allows you to publish your Web Application Project to a file system location. I'd like to do this on my TeamCity build server, so I need to do it with the solution runner or msbuild. I tried using the Publish target, but I think that might be for ClickOnce:</p>
  
  <pre><code>msbuild Project.csproj /t:Publish /p:Configuration=Deploy
  </code></pre>
  
  <p>I basically want to do exactly what a web deployment project does, but without the add-in. I need it to compile the WAP, remove any files unnecessary for execution, perform any <a href="http://msdn.microsoft.com/en-us/library/dd465326.aspx" rel="noreferrer">web.config transformations</a>, and copy the output to a specified location.</p>
  
  <p><strong>My Solution</strong>, based on Jeff Siver's answer</p>
  
  <pre><code>&lt;Target Name="Deploy"&gt;
      &lt;MSBuild Projects="$(SolutionFile)" 
               Properties="Configuration=$(Configuration);DeployOnBuild=true;DeployTarget=Package" 
               ContinueOnError="false" /&gt;
      &lt;Exec Command="&amp;quot;$(ProjectPath)\obj\$(Configuration)\Package\$(ProjectName).deploy.cmd&amp;quot; /y /m:$(DeployServer) -enableRule:DoNotDeleteRule" 
            ContinueOnError="false" /&gt;
  &lt;/Target&gt;
  </code></pre>