The first answer works on any release after Visual Studio 2005, but it seems a little flaky. I had to put a 1 second delay before clearing the console and couldn't get it any better than that. No idea why, but it's better than nothing. It also only works if you're only running one instance of Visual Studio. Maybe I"ll make an extension that looks at the RunningObjectTable to pick the right version.
At any rate, this works more or less.
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace VisualStudioHelper {
public class VstHelper {
// Add a Project Reference to "Microsoft Development Environment Properties 8.0"
// (the one for Visual Studio, not SQL Server)
public static void VstClearOutputWindow() {
if (!Debugger.IsAttached)
return;
Application.DoEvents();
Thread.Sleep(1000);
EnvDTE80.DTE2 ide = (EnvDTE80.DTE2)Marshal.GetActiveObject("VisualStudio.DTE.10.0");
ide.ExecuteCommand("Edit.ClearOutputWindow", "");
Marshal.ReleaseComObject(ide);
}
}
}