No, you certainly did not try "all methods". :-)
The method of capturing is well known, because all IDE need it. Good or bad, but traditionally all compilers and other build tools (like MSBuild.EXE) are created as separate command line applications and run in separate processes by IDE. For example, Visual Studio never builds .NET projects but uses compilers, MSBuild and other tools bundled with every version of (freely redistributable) .NET Framework. Nevertheless, you never see "raw" console, because all the output (in fact, too streams: standard output and standard error) are redirected to UI if the IDE.
You can do it by using the method
System.Diagnostics.Process.Start(ProcessStartInfo)
with re-directed
StandardOutput
and
StandardError
. You should remember to set the flags
System.Diagnostics.ProcessStartInfo.RedirectStandardOutput
and
System.Diagnostics.ProcessStartInfo.RedirectStandardError
.
See:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.aspx[
^].
You can find a simple code sample for redirection and basic explanations here:
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx[
^].
—SA