How do I force MSBuild to clean or rebuild?

John picture John · Sep 19, 2012 · Viewed 33k times · Source

I am using MSBuild from a script to compile my project. I have noticed that it just does a build and not a clean/rebuild.

I have the following:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
<Target Name="Build">
    <MSBuild Projects="$(MSBuildProjectDirectory)\myproj.csproj" Targets="Build" Properties="OutputPath=$(MSBuildProjectDirectory)\..\bin\" />
 </Target>

How do I force a clean/rebuild?

Answer

Geograph picture Geograph · May 7, 2015

"%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild" Project.sln /p:Configuration=Release /t:Rebuild