如何在Visual Studio输出窗口中运行控制台应用程序,而不是打开新的命令提示符?

时间:2022-05-18 20:45:43

I'm developing a simple console application in Visual Studio 2008 and want to run it in the output window inside Visual Studio 2008, instead of having a separate command prompt window come up. Is there a way to do this?

我正在Visual Studio 2008中开发一个简单的控制台应用程序,并希望在Visual Studio 2008中的输出窗口中运行它,而不是出现一个单独的命令提示符窗口。有没有办法做到这一点?

5 个解决方案

#1


19  

If you run the console app in the post build step it's output will go to the output window. The inability to do this easily has been on of my biggest peeves with VS (any version)

如果您在后期构建步骤中运行控制台应用程序,它的输出将转到输出窗口。无法轻易做到这一点是我最大的烦恼VS(任何版本)

#2


13  

ctrl+F5 seems to "start without debugging" in the debugging menu.

ctrl + F5似乎在调试菜单中“无需调试启动”。

#3


6  

Does it actually have to be a console application? If you make it a WinForms app (even though it doesn't create any GUI elements) you'll get the console output in the Output window. However, you then can't read from console input, and obviously you won't get any output at all if you run from a real command line or in explorer. For simple test applications this may be fine, of course!

它实际上必须是一个控制台应用程序吗?如果你把它变成WinForms应用程序(即使它没有创建任何GUI元素),你将在Output窗口中获得控制台输出。但是,您无法从控制台输入读取,显然,如果从真实的命令行或在资源管理器中运行,则根本不会获得任何输出。对于简单的测试应用,这当然可能没问题!

#4


3  

The only way I know of is to add it as an external tool and tick the Use output window checkbox when you define the tool.

我知道的唯一方法是将其添加为外部工具,并在定义工具时勾选“使用输出窗口”复选框。

#5


1  

It is a fairly old question, but as there is no answer marked as solution yet, try the answer given over here: Having the output of a console application in Visual Studio instead of the console

这是一个相当古老的问题,但由于还没有标记为解决方案的答案,请尝试在此处给出的答案:在Visual Studio中输出控制台应用程序而不是控制台

#1


19  

If you run the console app in the post build step it's output will go to the output window. The inability to do this easily has been on of my biggest peeves with VS (any version)

如果您在后期构建步骤中运行控制台应用程序,它的输出将转到输出窗口。无法轻易做到这一点是我最大的烦恼VS(任何版本)

#2


13  

ctrl+F5 seems to "start without debugging" in the debugging menu.

ctrl + F5似乎在调试菜单中“无需调试启动”。

#3


6  

Does it actually have to be a console application? If you make it a WinForms app (even though it doesn't create any GUI elements) you'll get the console output in the Output window. However, you then can't read from console input, and obviously you won't get any output at all if you run from a real command line or in explorer. For simple test applications this may be fine, of course!

它实际上必须是一个控制台应用程序吗?如果你把它变成WinForms应用程序(即使它没有创建任何GUI元素),你将在Output窗口中获得控制台输出。但是,您无法从控制台输入读取,显然,如果从真实的命令行或在资源管理器中运行,则根本不会获得任何输出。对于简单的测试应用,这当然可能没问题!

#4


3  

The only way I know of is to add it as an external tool and tick the Use output window checkbox when you define the tool.

我知道的唯一方法是将其添加为外部工具,并在定义工具时勾选“使用输出窗口”复选框。

#5


1  

It is a fairly old question, but as there is no answer marked as solution yet, try the answer given over here: Having the output of a console application in Visual Studio instead of the console

这是一个相当古老的问题,但由于还没有标记为解决方案的答案,请尝试在此处给出的答案:在Visual Studio中输出控制台应用程序而不是控制台