-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug multiple ASP.NET Core projects in Visual Studio Code #1441
Comments
The error you're getting is because your tasks.json is trying to pass two projects to "dotnet build" at the same time, which isn't supported. You would get the same error at the command line if you tried to execute "dotnet build Api Web". If you need to build multiple projects that don't reference one another, you'll either need to execute "dotnet build" twice, or add both projects to a solution and build that. However, if one of the projects references the other, you only need to build the top-level project. So, if "Web" references "Api", you only need to build "Web". |
Given your project structure, I suppose you want to pass "solution.sln" in the args to "dotnet build" in your tasks.json. As for debugging, is "api" a library or an executable? |
@mdmoura: Did the information I added above help at all? |
I am now trying with 2 different type projects (API= DotNet Web and Seed = DotNet Console). Not sure what do you mean with "passing solution.sln to args in dotnet build" in the context os VSCode. For the following structure:
I have the following launch.json:
And the tasks.json is (following your suggestion):
But I get the error: Any idea how to solve this? The reason why I am trying to work with a solution instead of individual projects in VSCode is that when I work with individual projects folders I have C# intellisense problems in projects that dependes on others due to Ominsharp. |
This can happen if you reference projects outside of the folder you have opened in VS Code. We've made some improvement around this behavior for the next release of C# for VS Code (#963).
Are you opening VS Code on an individual folder, or did you open it on the folder that contains your .vscode folder? If the currently opened folder in VS Code does not contain your .vscode folder with the tasks.json, I don't believe VS Code will find it. |
@DustinCampbell Any ETA for that release? I suppose it 1.1.0?
I opened on the solution folder so I can see this in VSCode's Explorer panel:
|
Correct. There is a beta available that you can try if you're interested. Use the Installing Beta Releases instructions if you'd like to try it. |
Your tasks.json looks to me like it should work. I just used {
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}/test-web.csproj"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
} Pressing F5 successfully ran the build task and launched the application. |
Try this also
|
There's an extension I use: rozzzly-dev.vscode-prompt-debug. Edit First run you'll have to choose "Enter path" and replace Luckily, it has a command history. I've opened an issue/request for appropriate netcore support. |
Thanks @jchannon and @DustinCampbell ! Steps: b) Then on tasks.json, i´ve pointed to my solution on args value: {
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": ["${workspaceRoot}/slnTcsErpFullDesenvWeb.sln"],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}
c) And on my launch.json: {
"version": "0.2.0",
"configurations": [
{
"name": "Tcs View Web Development",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/Tcs.Erp.UI.Web/bin/Debug/netcoreapp2.0/Tcs.Erp.UI.Web.dll",
"args": [],
"cwd": "${workspaceRoot}/Tcs.Erp.UI.Web",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceRoot}/Views"
}
},
{
"name": "Tcs Api Development",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program":
"${workspaceRoot}/Tcs.Erp.Api/bin/Debug/netcoreapp2.0/Tcs.Erp.Api.dll",
"args": [],
"cwd": "${workspaceRoot}/Tcs.Erp.Api",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceRoot}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
],
"compounds": [
{
"name": "Debug Tcs View and API Dev Mode",
"configurations": [
"Tcs View Web Development",
"Tcs Api Development"
]
}
]
}
|
My Tasks.json looks as below . No Solution name is needed, Dotnet build just picks up the Solution from the Workspace root folder or the folder itself. {
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}"
],
"problemMatcher": "$msCompile"
}
]
} And My Launch.json looks like below . This allows various configurations to be shown in 'Debug' Window (CTRL+SHIFT+D). and you can launch all the projects one by one from the same Visual Studio Code Window. {
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (Auth)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Auth/bin/Debug/netcoreapp2.0/Auth.dll",
"args": [],
"cwd": "${workspaceFolder}/Auth",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS":"http://localhost:5000"
}
},
{
"name": ".NET Core Launch (UI)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/UI/bin/Debug/netcoreapp2.0/UI.dll",
"args": [],
"cwd": "${workspaceFolder}/UI",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS":"http://localhost:5002"
}
},
{
"name": ".NET Core Launch (API)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Api/bin/Debug/netcoreapp2.0/Api.dll",
"args": [],
"cwd": "${workspaceFolder}/Api",
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS":"http://localhost:5001"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
} Visual Studio Code version below
DotNet Version 2.0.0 and whole thing just works |
When I launch compounds configs the VS Code show message: The task 'build is already active. |
@DostoevskyMF we aren't experts on the VS Code compound config feature, but based on your description I would guess the issue is that all of your debug configurations have |
Hi all, I am doing this on .net 2.2. I have breakpoints in both console apps and code only breaks on one console app. This should not matter but I am running vscode on CENTOS-7. Thanks |
@bumblebee333 I don't know of any reasons why that wouldn't work. Rather than re purposing this issue, can you open a new issue with some repro steps (ex: what does your launch.json look like) and logging. |
Sorry @gregg-miskelly I didn't mean to hijack this but my issue seemed similar. I am able to solve it by adding "externalConsole":true in launch.json for one of the console apps. The other one is set to: "console": "internalConsole". If I run into another issue I will definitely open a new one. |
Moved from microsoft/vscode#25628
From @mdmoura
I have the following ASP.NET Core solution (solution.sln) structure in VS Code:
I need to debug both api.csproj and web.csproj so I added the launch.json:
And the following tasks.json:
But when I debug it I get the following error:
I have tried different options but I always end with some kind of error some not even related with MSBUILD.
What is the proper way to debug multiple ASP.NET CORE projects in Visual Studio Code?
The text was updated successfully, but these errors were encountered: