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?
问题:
回答1:
Rebuild = Clean + Build (usually)
Notable details:
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). This difference in sequencing of events can become significant when inter-project dependencies come into play.
All three actions correspond to MSBuild targets. So a project can override the Rebuild action to do something completely different.
回答2:
Earl 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 actions before initiating a clean + build (or to remove them entirely).
Very much a corner case but pointing it out due to comment discussions.
回答3:
1 Per project, Rebuild project = (Clean project + Build project).
2 Per Solution, Rebuild Sln = foreach project (Clean project + Build project) != Clean Sln + Build Sln
Say you have a Sln, contains proj1, proj2, and proj3.
Rebuild Sln = (Clean proj1 -> Build Proj1) + (Clean proj2 -> Build Proj2) + (Clean proj3 -> Build Proj3)
Clean Sln + Build Sln = (Clean proj1 + Clean proj2 + Clean proj3) -> (Build proj1 + Build proj2 + Build proj3)
-> means serial, + means concurrent
so there is a chance when you submit a lot of code changes while you don't configured the project dependencies correctly, Rebuild Sln would cause some of you proj link to a stale lib because all builds aren't guaranteed being after all cleans.(In this case, Clean Sln + Build Sln will give a link error, and let you know that immediately, instead of giving you an app with odd behavior)
回答4:
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.
回答5:
From this blog post which the author linked as a comment on this question:
Actually No!!! they are not equal.
The difference is in the sequence projects get clean and build. Let say we have two projects in a solution. Clean and then build will perform clean to both projects and then build will occur individually while on rebuild project A will get and clean and then build after that project B will be clean and then build and so on.