Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture console output for debugging in VS?

Under VS's external tools settings there is a "Use Output Window" check box that captures the tools command line output and dumps it to a VS tab.

The question is: can I get the same processing for my program when I hit F5?

Edit: FWIW I'm in C# but if that makes a difference to your answer then it's unlikely that your answer is what I'm looking for.

What I want would take the output stream of the program and transfer it to the output tab in VS using the same devices that output redirection ('|' and '>') uses in the cmd prompt.

like image 752
BCS Avatar asked Sep 23 '08 18:09

BCS


1 Answers

You should be able to capture the output in a text file and use that.

I don't have a VS handy, so this is from memory:

  1. Create a C++ project
  2. Open the project settings, debugging tab
  3. Enable managed debugging
  4. Edit command line to add "> output.txt"
  5. Run your program under the debugger

If things work the way I remember, this will redirect STDOUT to a file, even though you're not actually running under CMD.EXE.

(The debugger has its own implementation of redirection syntax, which is not 100% the same as cmd, but it's pretty good.)

Now, if you open this file in VS, you can still see the output from within VS, although not in exactly the same window you were hoping for.

like image 126
Jay Bazuzi Avatar answered Oct 22 '22 05:10

Jay Bazuzi