在重建之前有什麼辦法讓Visual Studio 2010提示,或者其他任何方式來避免碰到「重建」而不是「構建」?重建之前Visual Studio 2010可以提示嗎?
我已經浪費了無數個小時,當我右鍵點擊一個項目並選擇意外點擊「Build」時的「Rebuild」。
這是針對本機C++解決方案的。
在重建之前有什麼辦法讓Visual Studio 2010提示,或者其他任何方式來避免碰到「重建」而不是「構建」?重建之前Visual Studio 2010可以提示嗎?
我已經浪費了無數個小時,當我右鍵點擊一個項目並選擇意外點擊「Build」時的「Rebuild」。
這是針對本機C++解決方案的。
Visual Studio 2010允許自定義菜單。您可以從Project上下文菜單中刪除「重建」項目。或者,您可能只想將「重建」命令從「構建」命令中移開,以免意外碰到錯誤的項目。
從2010年VS,
儘管我們以同樣的方式回答,但我贊成你的,因爲這是你的第一個答案。讓他們繼續來! :) – 2013-02-19 17:52:00
你確定你沒有註冊,因爲他比你高嗎? ;) – 2013-02-19 19:17:21
謝謝你們這個工作非常好。 – pauld 2013-02-19 21:40:24
據我所知,沒有辦法啓用執行項目或解決方案重建的確認。
您最好的選擇是移動或刪除上下文菜單上的「重建」菜單項。
要將菜單重置爲默認狀態,請單擊「全部重置」按鈕。
添加一個新的子菜單名爲「重建」
移動(刪除然後添加)真正的重建命令到這個新的菜單。如果你喜歡,重新命名爲「確定」。
您可以使用下面的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命令。
我剛打F7時,我想建立。當然,它確實構建了整個解決方案,但這正是你想要的。另一種方法是設置項目構建的快捷方式,這樣可以避免基於鼠標的混淆。 – 2013-02-19 17:32:34
是的,我想我必須養成使用F7構建整個解決方案的習慣。儘管我經常在我的情況下構建單個項目。 – pauld 2013-02-19 21:42:16