C# 选择解决方案下的哪个项目在 Visual Studio 2010 中调试或运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10004685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Selecting which project under a solution to debug or run in Visual Studio 2010
提问by Parris
This one should be easy. I just can't figure out what to search for...
这个应该很容易。我就是不知道要搜索什么...
For this one solution I created a unit test project, and I've been adding unit tests frantically. When I went back to try to run the original project after making all the unit tests pass I realized that I couldn't figure out how to debug the original project.
对于这个解决方案,我创建了一个单元测试项目,并且我一直在疯狂地添加单元测试。当我在所有单元测试通过后回去尝试运行原始项目时,我意识到我无法弄清楚如何调试原始项目。
In other words, every time I try to "debug" (e.g., by pressing F5), Visual Studio will run the unit tests. So the question is how do I run various projects in a single solution? How do I select which one will run when I want it to?
换句话说,每次我尝试“调试”(例如,按F5)时,Visual Studio 都会运行单元测试。所以问题是我如何在一个解决方案中运行各种项目?我如何选择在我想要的时候运行哪一个?
采纳答案by Justin Pihony
回答by Eric J.
You can right-click a project and set it as the Startup Project. It then is debugged when you press F5, or run when you press Ctrl-F5.
您可以右键单击一个项目并将其设置为启动项目。然后按 F5 进行调试,或按 Ctrl-F5 运行。
You can right-click a project and select Debug / Start new instanceto debug a project that is not the startup project.
您可以右键单击一个项目并选择Debug / Start new instance调试一个不是启动项目的项目。
On a side note, you can run / debug the unit tests without setting the unit test project as the startup one. There are icons (and keyboard shortcuts) in the toolbar to run or debug unit tests at various scopes (if not visible right-click your toolbar and select Test Tools).
附带说明一下,您可以运行/调试单元测试,而无需将单元测试项目设置为启动项目。工具栏中有图标(和键盘快捷键)可以在各种范围内运行或调试单元测试(如果不可见,请右键单击工具栏并选择测试工具)。
回答by K J
1) In the Solution-Explorer, right-click on the project that is the project for the executable assembly, and select "Set as Startup Project". This will make the project show in bold, and will be run automatically when you press F5.
1) 在解决方案资源管理器中,右键单击作为可执行程序集项目的项目,然后选择“设置为启动项目”。这将使项目以粗体显示,并在您按 F5 时自动运行。
2) Alternatively, in the Solution-Explorer, right-click on the project that is the project for the executable assembly, and select "Debug -> Start New Instance". This will start the debug session immediately.
2) 或者,在解决方案资源管理器中,右键单击作为可执行程序集项目的项目,然后选择“调试-> 启动新实例”。这将立即启动调试会话。
回答by Furkan Ekinci
This was my quickly Startup Project change way for me:
这是我对我的快速启动项目更改方式:
- Tools> Customize> Commands Tab.
- Choose Toolbarselection
- Select Standardtoolbar.

- Choose a place by mouse for new icon on menu preview and click Add Command...button
- Go to Projectitem on Categorieslist on opened Add Commandwindow.
- Select Set as Startup Projectitem on Commandslist

- Now, you can Setcurrent project as Startup Projectjust one click

- 工具>自定义>命令选项卡。
- 选择工具栏选择
- 选择标准工具栏。

- 用鼠标在菜单预览上为新图标选择一个位置,然后单击添加命令...按钮
- 在打开的添加命令窗口中转到类别列表上的项目项目。
- 在命令列表中
选择设置为启动项目项

- 现在,您可以一键
将当前项目设置为启动项目

But today I want more quickly way, then I finally found a way to set a shortcut for Set as Startup Project menu.
但是今天我想要更快的方法,然后我终于找到了一种方法来设置设置为启动项目菜单的快捷方式。
Just set a shortcut for "ClassViewContextMenus.ClassViewProject.Debug.Startnewinstance" item at Tools> Options> Enviroment> Keyboard
只需在“工具”>“选项”>“环境”>“键盘”中为“ ClassViewContextMenus.ClassViewProject.Debug.Startnewinstance”项目设置快捷方式
I set Ctrl + Alt + Shift + F5
我设置了 Ctrl + Alt + Shift + F5
回答by mdzeko
I wanted to debug a single console app project, and it is as simple as that:
我想调试一个控制台应用程序项目,就这么简单:
- Select the project in the Visual Studio run menu:

- You can even add debug parameters in the project properties:

That's it. You can right-click the project and press "Start new instance", 
or press F5, or click the "play" button visible in the first image.
或按 F5,或单击第一张图像中可见的“播放”按钮。

