简体   繁体   English

如何在Visual Studio中构建和运行多个项目

[英]How to build and run multiple projects in Visual Studio

There are many, many projects in the VS solution my company has. 我公司的VS解决方案中有很多项目。 Thing is, I need to build and run these 4 different C# projects of that solution: A , B , C and D , in that order. 问题是,我需要按该顺序构建和运行该解决方案的这4个不同的C#项目: ABCD

How do I achieve that without buildrunning each separately. 如何在不分别运行的情况下实现这一目标。

I hope I'm not asking a duplicate question, but I'm really not sure what terms should I use to search for an already answered duplicate. 我希望我不要问一个重复的问题,但是我真的不确定我应该使用什么术语来搜索已经回答的重复项。

Building/Running your projects as a group is easy, but building them in your own order is not. 以组的形式构建/运行项目很容易,但是以您自己的顺序构建它们却不是。 Remember that dependencies determine the order in which projects are built. 请记住,依赖关系决定了项目的生成顺序。

To build them as a group, simply place them all in the same Solution folder and invoke build on them: 要将它们作为一个组构建,只需将它们全部放在同一个Solution文件夹中并在其上调用build: 组建

To run them as a group, you have a few choices: 要将它们作为一个组运行,您有几种选择:

  1. Use the Solution Properties to run multiple projects (VS will run them "simultaneously" - you won't have control over the order). 使用解决方案属性运行多个项目(VS将“同时”运行它们-您将无法控制订单)。
  2. Use Project Properties to run a batch file as an external application. 使用项目属性将批处理文件作为外部应用程序运行。 In the batch file you can run them in a certain order. 在批处理文件中,您可以按特定顺序运行它们。
  3. Create a 'Launcher' project to launch the projects in any order you like, with any delays you like, check that one app is initialized before running the next, etc. 创建一个“ Launcher”项目,以您喜欢的任何顺序启动项目,并希望有任何延迟,在运行下一个应用程序之前检查它是否已初始化,等等。

When you run a project, VS will automatically do any and all building necessary to run your startup project. 当您运行一个项目时,VS将自动执行运行启动项目所需的任何和所有构建。 It will also determine this order for you based on the dependency tree. 它还将根据依赖关系树为您确定此顺序。 You shouldn't need to edit this under most circumstances. 在大多数情况下,您无需进行编辑。 VS lets you do so by editing the dependencies. VS使您可以通过编辑依赖项来实现。 Right click on your project and select Build Dependencies > Project Build Order to see the current build order and edit your dependencies, which will affect the build order. 右键单击您的项目,然后选择“ Build Dependencies >“ Project Build Order以查看当前的构建顺序并编辑您的依赖关系,这将影响构建顺序。

While debugging, you can right click on another project you want to run and select Debug > Start New Instance to run that project in addition to your startup project. 调试时,除了启动项目之外,您还可以右键单击要运行的另一个项目,然后选择“调试”>“启动新实例”以运行该项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何构建和部署具有多个项目的Visual Studio解决方案 - How to build and deploy a visual studio solution with multiple projects 如何在 Visual Studio 2019 中本地运行多个 Azure .net 5 函数项目? - How Can I run multiple Azure .net 5 Function Projects locally in Visual Studio 2019? 如何在Visual Studio中查看所有项目的构建事件? - How to see the build events for all projects in Visual Studio? Visual Studio 2010:如何在解决方案中强制执行项目的构建顺序? - Visual Studio 2010: How to enforce build order of projects in a solution? 如何在活动的Visual Studio配置中构建项目? - How do I get the projects to build in the active Visual Studio configuration? Visual Studio中的多语言项目 - Multiple Language Projects in Visual Studio 在 Visual Studio 中处理多个项目 - Handling multiple projects in Visual Studio 在 Visual Studio 中关闭多个项目 - Closing multiple projects in Visual Studio 如何在Visual Studio的Mediam级别信任上运行Web项目 - How to run web projects on Mediam level trust on visual studio 在 Visual Studio Online Build Definition 中从具有多个 Web 项目的解决方案构建一个 Web 项目 - Build one web project from a Solution with multiple web projects in Visual Studio Online Build Definition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM