我如何 run/debug 基于解决方案配置的给定项目?
How can I run/debug a given project based on the solution configuration?
我在一个解决方案中有多个项目。主要的两个“可运行”项目是服务器和客户端。 “Run/Debug”按钮旁边的下拉列表显示“调试”和“发布”。这似乎是管理多个“项目配置”的“解决方案配置”。我正在寻找一种方法来用“调试客户端”、“发布客户端”、“调试服务器”和“发布服务器”的“解决方案配置”替换它们。
有了这个,我希望简单地 selecting 任何配置并点击播放就能构建正确的“项目配置”AND run/debug 预期的项目。
但是,我找不到任何设置来决定实际启动哪个项目。仅“构建”/“部署”。
我仍然需要手动 select 将哪个项目“设置为启动项目”。
我可以在解决方案属性中看到我可以设置多个启动项目。这个“属性”页面绝对完美如果我能够更改左上角的“配置”,但是整个config/platform-area是用“N/A”变灰。我只能在一般层面上更改它,如果我将客户端和服务器都更改为“启动”,那么它们总是启动,这绝对不是我想要的。我只想根据我选择的解决方案配置开始。这不可能吗?
我找到了一个名为 SwitchStartupProject 的扩展程序,它可以实现您想要的功能。使用此扩展,您可以配置以 JSON 编写的解决方案启动文件。例如,我是这样写的:
{
/* Configuration File Version */
"Version": 3,
/* Create an item in the dropdown list for each project in the solution? */
"ListAllProjects": false,
"MultiProjectConfigurations": {
"ProjectA": { /* Configuration name (appears in the dropdown) */
"Projects": {
"ProjectA": {} /* Starting ProjectA */
},
"SolutionConfiguration": "ProjectAConfig", /* Activating solution configuration "ProjectAConfig" */
"SolutionPlatform": "Any CPU" /* and solution platform "Any CPU" */
},
"ProjectB": { /* Configuration name (appears in the dropdown) */
"Projects": {
"ProjectB": {} /* Starting ProjectB */
},
"SolutionConfiguration": "ProjectBConfig", /* Activating solution configuration "ProjectBConfig" */
"SolutionPlatform": "x86" /* and solution platform "x86" */
},
"netcoreapi": { /* Configuration name (appears in the dropdown) */
"Projects": {
"netcoreapi": {} /* Starting netcoreapi*/
},
"SolutionConfiguration": "Debug", /* Activating solution configuration "Debug" */
"SolutionPlatform": "Any CPU" /* and solution platform "Any CPU" */
}
}
}
结果:
您 select 您想要启动哪个项目,而不是更改您想要的配置,而这又可以更改使用的配置。您甚至可以更改平台以及演示等。查看扩展程序的 configuration 页面以了解更多信息。
我在一个解决方案中有多个项目。主要的两个“可运行”项目是服务器和客户端。 “Run/Debug”按钮旁边的下拉列表显示“调试”和“发布”。这似乎是管理多个“项目配置”的“解决方案配置”。我正在寻找一种方法来用“调试客户端”、“发布客户端”、“调试服务器”和“发布服务器”的“解决方案配置”替换它们。 有了这个,我希望简单地 selecting 任何配置并点击播放就能构建正确的“项目配置”AND run/debug 预期的项目。 但是,我找不到任何设置来决定实际启动哪个项目。仅“构建”/“部署”。 我仍然需要手动 select 将哪个项目“设置为启动项目”。
我可以在解决方案属性中看到我可以设置多个启动项目。这个“属性”页面绝对完美如果我能够更改左上角的“配置”,但是整个config/platform-area是用“N/A”变灰。我只能在一般层面上更改它,如果我将客户端和服务器都更改为“启动”,那么它们总是启动,这绝对不是我想要的。我只想根据我选择的解决方案配置开始。这不可能吗?
我找到了一个名为 SwitchStartupProject 的扩展程序,它可以实现您想要的功能。使用此扩展,您可以配置以 JSON 编写的解决方案启动文件。例如,我是这样写的:
{
/* Configuration File Version */
"Version": 3,
/* Create an item in the dropdown list for each project in the solution? */
"ListAllProjects": false,
"MultiProjectConfigurations": {
"ProjectA": { /* Configuration name (appears in the dropdown) */
"Projects": {
"ProjectA": {} /* Starting ProjectA */
},
"SolutionConfiguration": "ProjectAConfig", /* Activating solution configuration "ProjectAConfig" */
"SolutionPlatform": "Any CPU" /* and solution platform "Any CPU" */
},
"ProjectB": { /* Configuration name (appears in the dropdown) */
"Projects": {
"ProjectB": {} /* Starting ProjectB */
},
"SolutionConfiguration": "ProjectBConfig", /* Activating solution configuration "ProjectBConfig" */
"SolutionPlatform": "x86" /* and solution platform "x86" */
},
"netcoreapi": { /* Configuration name (appears in the dropdown) */
"Projects": {
"netcoreapi": {} /* Starting netcoreapi*/
},
"SolutionConfiguration": "Debug", /* Activating solution configuration "Debug" */
"SolutionPlatform": "Any CPU" /* and solution platform "Any CPU" */
}
}
}
结果:
您 select 您想要启动哪个项目,而不是更改您想要的配置,而这又可以更改使用的配置。您甚至可以更改平台以及演示等。查看扩展程序的 configuration 页面以了解更多信息。