天天看點

Visual Studio中Rebuild和Clean + Build之間的差別

本文翻譯自:Difference between Rebuild and Clean + Build in Visual Studio

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

隻是重建和在Visual Studio 2008中執行Clean + Build之間有什麼差別?

Is Clean + Build different then doing Clean + Rebuild ?

Clean + Build是不同的,然後做Clean + Rebuild ?

#1樓

參考:https://stackoom.com/question/5ewh/Visual-Studio中Rebuild和Clean-Build之間的差別

#2樓

Rebuild = Clean + Build (usually)

重建=清潔+建造(通常)

Notable details:

值得注意的細節:
  1. 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. 當項目間的依賴關系發揮作用時,事件排序的這種差異會變得很大。
  2. All three actions correspond to MSBuild targets. 所有這三個操作都對應于MSBuild目标。 So a project can override the Rebuild action to do something completely different. 是以,項目可以覆寫重建操作以執行完全不同的操作。

#3樓

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

Earl是正确的,99%的時間Rebuild = Clean + Build。

But they are not guaranteed to be the same.

但它們并不保證是一樣的。

The 3 actions (rebuild, build, clean) represent different MSBuild targets.

3個動作(重建,建構,清理)代表不同的MSBuild目标。

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).

是以,在啟動clean + build(或完全删除它們)之前,某人完全有可能覆寫rebuild以執行多個操作。

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

非常一個極端的案例,但由于評論讨論指出它。

#4樓

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

來自http://www.cs.tufts.edu/r/graphics/resources/vs_getting_started/vs_getting_started.htm ,(隻是谷歌搜尋):

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.

建構或重建解決方案建構或重建解決方案中的所有項目,而建構或重建建構或重建StartUp項目,在上面的螢幕截圖中“hello”。

To set the StartUp project, right click on the desired project name in the Solution Explorer tab and select Set as StartUp project.

要設定StartUp項目,請在Solution Explorer頁籤中右鍵單擊所需的項目名稱,然後選擇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.

Ctrl-F7是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. 清理然後建構将對兩個項目執行清理,然後在重建項目A時将單獨進行建構将獲得并清理然後在該項目B之後建構B将是幹淨的,然後建構等等。

#6樓

1 Per project, Rebuild project = (Clean project + Build project).

1每個項目,重建項目=(清理項目+建構項目)。

2 Per Solution, Rebuild Sln = foreach project (Clean project + Build project) != Clean Sln + Build Sln

2每個解決方案,重建Sln = foreach項目(清理項目+建構項目)!= Clean Sln + Build Sln

Say you have a Sln, contains proj1, proj2, and proj3.

假設您有一個Sln,包含proj1,proj2和proj3。

Rebuild Sln = (Clean proj1 -> Build Proj1) + (Clean proj2 -> Build Proj2) + (Clean proj3 -> Build Proj3)

重建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)

Clean Sln + Build Sln =(清潔proj1 + Clean proj2 + Clean proj3) - >(建構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)

是以,當您沒有正确配置項目依賴項時,有可能送出大量代碼更改,Rebuild Sln會導緻您的某些項目連結到陳舊的lib,因為所有建構都不能保證在完全清除之後。(在這種情況下,Clean Sln + Build Sln會給對外連結接錯誤,并立即通知您,而不是給您一個奇怪行為的應用程式)

繼續閱讀