Difference between Build Solution, Rebuild Solution, and Clean Solution in Visual Studio?

Fawa Source

What is the difference between Build Solution, Rebuild Solution, and Clean Solution in Visual Studio?

When is the appropriate time to use each one of these?

visual-studio

Answers

answered 8 years ago Matthew Jones #1

Taken from this link:

Build means compile and link only the source files that have changed since the last build, while Rebuild means compile and link all source files regardless of whether they changed or not. Build is the normal thing to do and is faster. Sometimes the versions of project target components can get out of sync and rebuild is necessary to make the build successful. In practice, you never need to Clean.

answered 8 years ago Steven Evers #2

Build solution will build any projects in the solution that have changed. Rebuild builds all projects no matter what, clean solution removes all temporary files ensuring that the next build is complete.

answered 8 years ago Justin Niessner #3

Build Solution - Builds any assemblies which have changed files. If an assembly has no changes, it won't be re-built. Also will not delete any intermediate files.

Used most commonly.

Rebuild Solution - Rebuilds all assemblies regardless of changes but leaves intermediate files.

Used when you notice that Visual Studio didn't incorporate your changes in the latest assembly. Sometimes Visual Studio does make mistakes.

Clean Solution - Delete all intermediate files and rebuild all assemblies regardless of changes

Used when all else fails and you need to clean everything up and start fresh.

answered 8 years ago Jon Skeet #4

  • Build solution will perform an incremental build: if it doesn't think it needs to rebuild a project, it won't. It may also use partially-built bits of the project if they haven't changed (I don't know how far it takes this)
  • Rebuild solution will clean and then build the solution from scratch, ignoring anything it's done before.
  • Clean solution will remove the build artifacts from the previous build. If there are any other files in the build target directories (bin and obj) they may not be removed, but actual build artifacts are. I've seen behaviour for this vary - sometimes deleting fairly thoroughly and sometimes not - but I'll give VS the benefit of the doubt for the moment :)

(The links are to the devenv.exe command line switches, but they do the same as the menu items.)

answered 8 years ago Ken Richards #5

I just think of Rebuild as performing the Clean first followed by the Build. Perhaps I am wrong ... comments?

answered 5 years ago Shivprasad Koirala #6

Build solution: Compiles code files (DLL and EXE) which are changed.

Rebuild: Deletes all compiled files and compiles them again irrespective if the code has changed or not.

Clean solution: Deletes all compiled files (DLL and EXE file).

You can see this YouTube video (Visual Studio Build vs. Rebuild vs. Clean (C# interview questions with answers)) where I have demonstrated the differences and below are visual representations which will help you to analyze the same in more detail.

Build vs Rebuild

The difference between Rebuild vs. (Clean + Build), because there seems to be some confusion around this as well:

The difference is the way the build and clean sequence happens for every project. Let’s say your solution has two projects, “proj1” and “proj2”. If you do a rebuild it will take “proj1”, clean (delete) the compiled files for “proj1” and build it. After that it will take the second project “proj2”, clean compiled files for “proj2” and compile “proj2”.

But if you do a “clean” and build”, it will first delete all compiled files for “proj1” and “proj2” and then it will build “proj1” first followed by “proj2”.

Rebuild Vs Clean

answered 4 years ago yashashwi #7

Build solution only builds those projects which have changed in the solution, and does not effect assemblies that have not changed,

ReBuild first cleans, all the assemblies from the solution and then builds entire solution regardless of changes done.

Clean, simply cleans the solution.

answered 2 years ago Guilherme Fidelis #8

Build Solution – Builds any assemblies which have changed files. If an assembly has no changes, it won’t be re-built. Also will not delete any intermediate files.

Rebuild solution will clean and then build the solution from scratch, ignoring anything it’s done before

Clean Solution will delete all compiled files (i.e., EXE’s and DLL’s) from the bin/obj directory.

answered 1 year ago Sabaridass R #9

Build Solution - Build solution will build your application with building the number of projects which are having any file change. And it does not clear any existing binary files and just replacing updated assemblies in bin or obj folder.

Rebuild Solution - Rebuild solution will build your entire application with building all the projects are available in your solution with cleaning them. Before building it clears all the binary files from bin and obj folder.

Clean Solution - Clean solution is just clears all the binary files from bin and obj folder.

answered 7 months ago Sajisha #10

Build solution

This will perform an incremental build. In other words it will only build code files which have changed. If they have not changed those files will not be touched.

Rebuild solution

This will delete all currently compiled files (i.e., exe and DLLs) and will build everything from scratch, irrespective of if there is code change in the file or not.

Clean solution menu

This menu will delete all compiled files (i.e., EXE’s and DLL’s) from the bin/obj directory.

Rebuild = Clean + Build

comments powered by Disqus