How to run a clean build for a particular project from a solution in visual studio

Use msbuild and pass the Clean and Rebuild targets:

msbuild path\to\solution\yoursolution.sln /t:Clean;Rebuild

Or if you only want to rebuild a single project:

msbuild path\to\project\yourproject.csproj /t:Clean;Rebuild

msbuild is available in the Windows SDK or the Visual Studio Command prompt.


MSBuild.exe MultiProjectSolution.sln /t:"ProjectName:clean"

Will clean only the specified project in your 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.

Build whole solution incrementally:

msbuild MySolutionFile

Note, that this will build default configuration/platform for the projects and solution, which is often Debug/AnyCPU or Debug/Win32. If you want specific configuration/platform, you have to add parameters like this: /p:Configuration=Release /p:Platform=x64 to every msbuild command line.