Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force MSBuild to clean or rebuild?

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?

like image 779
John Avatar asked Sep 19 '12 11:09

John


People also ask

How do you clean MSBuild solution?

Cleaning up specific projects: msbuild MyProjectFile1 /t:Clean msbuild MyProjectFile2 /t:Clean ... This has to be repeated for all projects you need to clean, because MSBuild only accepts single project on command line.

Is rebuild the same as clean and build?

For a multi-project solution, "rebuild solution" does a "clean" followed by a "build" for each project (possibly in parallel). Whereas a "clean solution" followed by a "build solution" first cleans all projects (possibly in parallel) and then builds all projects (possibly in parallel).

How do I run MSBuild manually?

To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.


2 Answers

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

like image 126
Geograph Avatar answered Nov 12 '22 05:11

Geograph


Change

<MSBuild Projects="$(MSBuildProjectDirectory)\myproj.csproj"   Targets="Build"   Properties="OutputPath=$(MSBuildProjectDirectory)\..\bin\" /> 

to

<MSBuild Projects="$(MSBuildProjectDirectory)\myproj.csproj"   Targets="Clean;Build"   Properties="OutputPath=$(MSBuildProjectDirectory)\..\bin\" /> 

or

<MSBuild Projects="$(MSBuildProjectDirectory)\myproj.csproj" Targets="Rebuild"   Properties="OutputPath=$(MSBuildProjectDirectory)\..\bin\" /> 

For more details, look at the MSBuild Task documentation.

like image 20
skolima Avatar answered Nov 12 '22 04:11

skolima