Any way to have Visual Studio prompt before rebuilding, or any other way to make it easier to avoid hitting \"Rebuild\" instead of \"Build\"?
I\'ve wasted countless
You can use the following C# extension for my Visual Commander tool:
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;
}
It asks to confirm all rebuild commands like Build.RebuildSolution, Build.RebuildSelection and Build.ProjectPickerRebuild.