From the msbuild.exe command-line, how do I do the equivalent of a Rebuild in the IDE?

If you're building a Visual Studio solution that contains only C#, VB, and VJ# projects, you can do:

msbuild.exe /t:rebuild foo.sln

If you're building a Visual Studio C#, VB, or VJ# project, you can do:

msbuild.exe /t:rebuild foo.csproj

or if you're running from the directory of the project, just run:

msbuild.exe /t:rebuild

"Rebuild" is a target defined in Microsoft.Common.targets which is imported by all Visual Studio C#, VB, and VJ# (""MSBuild"") projects.


Followup: How is the customer supposed to discover that this is the way to do a Rebuild from the command-line?

Answer: We do provide a brief example of this in the output of msbuild /?. However, the concept of "Rebuild" isn't really an ""MSBuild"" concept, so we didn't want to advertise it as though it would work for any hand-authored project. This is really a VS-specific concept.
Microsoft Communities