2013-02-19 41 views
15

在重建之前有什麼辦法讓Visual Studio 2010提示,或者其他任何方式來避免碰到「重建」而不是「構建」?重建之前Visual Studio 2010可以提示嗎?

我已經浪費了無數個小時,當我右鍵點擊一個項目並選擇意外點擊「Build」時的「Rebuild」。

這是針對本機C++解決方案的。

+0

我剛打F7時,我想建立。當然,它確實構建了整個解決方案,但這正是你想要的。另一種方法是設置項目構建的快捷方式,這樣可以避免基於鼠標的混淆。 – 2013-02-19 17:32:34

+0

是的,我想我必須養成使用F7構建整個解決方案的習慣。儘管我經常在我的情況下構建單個項目。 – pauld 2013-02-19 21:42:16

回答

27

Visual Studio 2010允許自定義菜單。您可以從Project上下文菜單中刪除「重建」項目。或者,您可能只想將「重建」命令從「構建」命令中移開,以免意外碰到錯誤的項目。

從2010年VS,

  • 選擇工具菜單
  • 選擇自定義...
  • 選擇命令選項卡
  • 選擇 「上下文菜單」 單選按鈕,然後選擇「項目和 解決方案上下文菜單|項目「
  • 選擇」重建「並移動或移除它。
+0

儘管我們以同樣的方式回答,但我贊成你的,因爲這是你的第一個答案。讓他們繼續來! :) – 2013-02-19 17:52:00

+0

你確定你沒有註冊,因爲他比你高嗎? ;) – 2013-02-19 19:17:21

+0

謝謝你們這個工作非常好。 – pauld 2013-02-19 21:40:24

9

據我所知,沒有辦法啓用執行項目或解決方案重建的確認。

您最好的選擇是移動或刪除上下文菜單上的「重建」菜單項。

  1. 右擊VS菜單/工具欄區域,然後選擇「自定義...」
  2. 單擊「命令」選項卡上。
  3. 選擇「上下文菜單」單選按鈕。
  4. 在下拉列表中找到「項目和解決方案上下文菜單|項目」。
  5. 單擊上下文菜單表示中的「重建」菜單項並執行所需的操作(刪除,上移或下移,開始新組等)。

要將菜單重置爲默認狀態,請單擊「全部重置」按鈕。

2

添加一個新的子菜單名爲「重建」

移動(刪除然後添加)真正的重建命令到這個新的菜單。如果你喜歡,重新命名爲「確定」。

0

您可以使用下面的C#擴展爲我Visual Commander工具:

public class E : VisualCommanderExt.IExtension 
{ 
    public void SetSite(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) 
    { 
     events = DTE.Events; 
     commandEvents = events.get_CommandEvents(null, 0); 
     commands = DTE.Commands as EnvDTE80.Commands2; 
     commandEvents.BeforeExecute += OnBeforeExecute; 
    } 

    public void Close() 
    { 
     commandEvents.BeforeExecute -= OnBeforeExecute; 
    } 

    private void OnBeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) 
    { 
     string name = GetCommandName(Guid, ID); 
     if (name.Contains("Rebuild")) 
     { 
      if (System.Windows.MessageBox.Show("Are you sure you want to Rebuild?", "Confirm", 
       System.Windows.MessageBoxButton.YesNo) != System.Windows.MessageBoxResult.Yes) 
      { 
       CancelDefault = true; 
      } 
     } 
    } 

    private string GetCommandName(string Guid, int ID) 
    { 
     if (Guid == null) 
      return "null"; 
     try 
     { 
      return commands.Item(Guid, ID).Name; 
     } 
     catch (System.Exception) 
     { 
     } 
     return ""; 
    } 

    private EnvDTE.Events events; 
    private EnvDTE.CommandEvents commandEvents; 
    private EnvDTE80.Commands2 commands; 
} 

它要求確認所有重建像Build.RebuildSolution,Build.RebuildSelection和Build.ProjectPickerRebuild命令。

相關問題