views:

2326

answers:

3

What is the difference between just a Rebuild and doing a Clean + Build in Visual Studio 2008? Is Clean + Build different then doing Clean + Rebuild?

+11  A: 

Rebuild = Clean + Build

earl
So you are saying that *Rebuild* is **exactly** the same as a *Clean* followed by a *Build*? That is kind of what I thought, but I wasn't sure.
Jim McKeeth
Yes, that's exactly what _rebuild_ is doing.
earl
OK, thanks!
Jim McKeeth
Except Rebuild cleans and the rebuilds each project one by one. Clean+Build cleans all of them and then builds all of them. Makes difference mostly if you click it by accident :)
Eugene
Except for the lack of guarantee that they are the same. See JaredPar's answer below which combined with Earl's is the whole picture. Because Rebuild does each project in turn, you can have a "corner case" when your dependency information is messed up and you get an out of order build project of B using the old project A then rebuild A, then rebuild C. etc. A full solution Clean followed by a full solution build will catch this situation while a rebuild won't. So the more paranoid and tired you are, the more you should favor towards Clean then Build.
Jason Harrison
This is not true. I have had a project where Clean + Build succeeded, and Rebuild returned compile errors (circular file references). So they are not 100% the same.
Yaakov Ellis
+17  A: 

Early is correct that 99% of the time Rebuild = Clean + Build.

But they are not guaranteed to be the same. The 3 actions (rebuild, build, clean) represent different MSBuild targets. Each of which can be overriden by any project file to do custom actions. So it is entirely possible for someone to override rebuild to do several actiions before initiating a clean + build (or to remove them entirely).

Very much a corner case but pointing it out due to comment discussions.

JaredPar
OK, good to know! Thanks.
Jim McKeeth
If you add build actions that move .dll files to a new location you can get 'bad' build results by just doing a rebuild.If you mix a vb.net and c# project things get even worse, broken form designers and no working goto.
Barfieldmv
+1  A: 

From http://www.cs.tufts.edu/r/graphics/resources/vs_getting_started/vs_getting_started.htm, (just googled it):

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.

Build or Rebuild Solution builds or rebuilds all projects in the your solution, while Build or Rebuild builds or rebuilds the StartUp project, "hello" in the screen shot above. To set the StartUp project, right click on the desired project name in the Solution Explorer tab and select Set as StartUp project. The project name now appears in bold. Since the homework solutions typically have only one project, Build or Rebuild Solution is effectively the same as Build or Rebuild .

Compile just compiles the source file currently being edited. Useful to quickly check for errors when the rest of your source files are in an incomplete state that would prevent a successful build of the entire project. Ctrl-F7 is the shortcut key for Compile.

EduardoMello