我正在尝试使用Visual Studio Code替代Visual Studio。我已经将工作区设置为充当解决方案文件,因此我可以从一个工作区中的不同目录引入多个项目(即“解决方案”)。在每个项目的根目录中都有一个.vscode
目录。在该.vscode
目录中有一个tasks.json
文件和一个launch.json
文件。
在我的launch.json
文件中,我有几种配置,然后有一种用于启动整个应用程序的化合物(由一堆.NET Core ASP.NET dll组成)。
问题出在我的launch.json
复合物上,用于启动应用程序。我称这个化合物为"Start All"
。当需要在启动应用程序之前重建一个或多个项目时,我的"Start All"
化合物将一次完成所有工作,而不确保在运行它之前便已真正构建了所有项目。最终结果是,并非所有单个项目都将被运行-需要构建的项目将出错(尽管代码中没有实际错误-它们已编译但没有运行)和已经构建的将开始运行。因此,我必须停止所有正在运行的项目...并再次运行"Start All"
复合,一切都将按预期启动并运行。
这种行为变得很烦人,以至于我最近编写了一个Python脚本来一个接一个地构建所有项目。这样,当我运行"Start All"
复合时,Visual Studio Code将真正启动所有项目。我已经考虑过制作一个"Build All"
复合(因此我必须运行"Build All"
,等待它完成,然后运行"Start All"
),但是看起来Visual Studio Code应该可以自动执行。
我不确定我的launch.json
文件设置是否错误,或者我是否高估了此刻Visual Studio Code的功能。这是一个基本功能,我以为我必须做错了什么。以下是与我的真实launch.json
和tasks.json
文件相似的示例。任何建议将不胜感激。
launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "App.Common",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-common-lib",
"program": "${workspaceFolder}/../../Common/App.Common/src/bin/Debug/netstandard2.0/App.Common.dll",
"args": [],
"cwd": "${workspaceFolder}/../../Common/App.Common/src",
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "Local"
}
},
{
"name": "App.Micro.Emails",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-emails-micro",
"program": "${workspaceFolder}/../../MyApp/App.Micro.Emails/src/bin/Debug/netcoreapp2.1/App.Micro.Emails.dll",
"args": [],
"cwd": "${workspaceFolder}/../../MyApp/App.Micro.Emails/src",
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "Local"
}
},
{
"name": "App.Micro.Organizations",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-organizations-micro",
"program": "${workspaceFolder}/../../MyApp/App.Micro.Organizations/src/bin/Debug/netcoreapp2.1/App.Micro.Organizations.dll",
"args": [],
"cwd": "${workspaceFolder}/../../MyApp/App.Micro.Organizations/src",
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "Local"
}
},
{
"name": "App.Worker.Migration",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-migration-worker",
"program": "${workspaceFolder}/src/bin/Debug/netcoreapp2.1/App.Worker.Migration.dll",
"args": [],
"cwd": "${workspaceFolder}/src",
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "Local"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
],
"compounds": [
{
"name": "Start All",
"configurations": [
"App.Common",
"App.Micro.Emails",
"App.Micro.Organizations",
"App.Worker.Migration"
]
},
]
}
tasks.json
:
{
"version": "2.0.0",
"tasks": [
{
"label": "build common lib",
"identifier": "build-common-lib",
"group": "build",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"${workspaceFolder}/../../Common/App.Common/src/App.Common.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "build organizations micro",
"identifier": "build-organizations-micro",
"group": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/../../MyApp/App.Micro.Organizations/src/App.Micro.Organizations.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "build emails micro",
"identifier": "build-emails-micro",
"group": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/../../MyApp/App.Micro.Emails/src/App.Micro.Emails.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "build migration worker",
"identifier": "build-migration-worker",
"group": "build",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"${workspaceFolder}/src/App.Worker.Migration.csproj"
],
"problemMatcher": "$msCompile"
}
]
}