Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Suppose I need to build a whole solution (which has multiple projects) in command line, is it possible to run a clean build for a particular projects and run an incremental build for the rest of the project?

Thanks.

like image 639
Kintarō Avatar asked Jan 16 '13 20:01

Kintarō


People also ask

How do I run a clean solution in Visual Studio?

To build, rebuild, or clean an entire solution Choose Build All to compile the files and components within the project that have changed since the most recent build. Choose Rebuild All to "clean" the solution and then builds all project files and components. Choose Clean All to delete any intermediate and output files.

How do you build specific targets in solutions using MSBuild EXE?

To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.

What is the Clean build code for Visual Studio?

On the menu bar, choose Build, and then choose either Build ProjectName or Rebuild ProjectName. Choose Build ProjectName to build only those project components that have changed since the most recent build. Choose Rebuild ProjectName to "clean" the project and then build the project files and all project components.

What does cleaning a solution do Visual Studio?

Clean Solution - deletes all compiled files (all dll's and exe's ). Build Solution - compiles code files (dll and exe) that have changed. Rebuild Solution - Deletes all compiled files and Compiles them again regardless of whether or not the code has changed.


2 Answers

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.

like image 51
jrummell Avatar answered Sep 28 '22 20:09

jrummell


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

Will clean only the specified project in your solution.

like image 41
Crypth Avatar answered Sep 28 '22 20:09

Crypth