Skip to content

Commit 178636b

Browse files
authored
Merge pull request #7123 from Particular/afprtclr-patch-1
Reviewing instructions for VS Code
2 parents 8cfe0fd + 919614f commit 178636b

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

nservicebus/vscode.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Debugging NServiceBus in Visual Studio Code
33
summary: How to configure Visual Studio Code to build and debug multiple NServiceBus endpoints simultaneously
44
component: Core
5-
reviewed: 2023-03-12
5+
reviewed: 2025-05-09
66
---
77

88
This article describes how to configure [Visual Studio Code](https://code.visualstudio.com/) (or "VS Code") to build an NServiceBus solution with multiple projects and debug multiple endpoints simultaneously.
@@ -14,7 +14,7 @@ While Visual Studio contains specific support for .NET projects, VS Code is a mo
1414
## Prerequisities
1515

1616
* This article assumes knowledge of NServiceBus solutions.
17-
* VS Code must have the [C# for Visual Studio Code (powered by OmniSharp)](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp) extension installed.
17+
* VS Code must have the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp) installed.
1818

1919
## Configuration files
2020

@@ -35,10 +35,9 @@ Both of these files can be generated from within VS Code, but the default values
3535

3636
To create the initial file:
3737

38-
1. Attempt to start debugging.
39-
2. Click **Configure Task** in the error dialog that appears.
40-
3. Select **Create tasks.json from template**.
41-
4. Select **.NET Core**.
38+
1. After opening a folder with the project in Visual Studio Code, you may receive a notification saying `Required assets to build and debug are missing. Add them?`. If you decide to add them, then Visual Studio Code will create predefined configurations like `.NET Core Launch`.
39+
1. Alternatively, you can click the button `Generate C# Assets for Build and Debug` in the `Run and Debug` pane.
40+
1. Alternatively, you can run the command **Tasks: Configure Task**, then **Create tasks.json from template**, and then select **.NET Core**.
4241

4342
The file created by VS Code may work as-is if the project contains only one solution file in the project's root directory.
4443

@@ -70,16 +69,15 @@ For more information on **tasks.json**, see [Visual Studio Code: Integrate with
7069

7170
To create the initial file:
7271

73-
1. In the Debug toolbar, click the **No Configurations** dropdown.
74-
1. Select **Add Configuration**.
75-
1. Select **.NET Core**.
72+
1. Run the command **Debug: Add Configuration**.
73+
1. Select **.NET 5+ and .NET Core**.
7674

7775
The high-level structure of the **launch.json** file contains a collection of individual project objects in `configurations` and an optional [`compounds` collection](#launch-json-compounds) that lists multiple configurations that should be launched at the same time.
7876

7977
```json
8078
{
8179
"version": "0.2.0",
82-
"configurations: [
80+
"configurations": [
8381

8482
],
8583
"compounds": [
@@ -98,7 +96,7 @@ Here is an example configuration for an NServiceBus endpoint hosted as a console
9896
"type": "coreclr",
9997
"request": "launch",
10098
"preLaunchTask": "build",
101-
"program": "${workspaceFolder}/path/to/Sales/bin/Debug/net5.0/Sales.dll",
99+
"program": "${workspaceFolder}/path/to/Sales/bin/Debug/net9.0/Sales.dll",
102100
"args": [],
103101
"cwd": "${workspaceFolder}/path/to/Sales",
104102
"stopAtEntry": false,
@@ -115,7 +113,7 @@ Most of the values can be considered boilerplate, except for the `program` and `
115113
* `program`: Identifies the DLL to use as the entry point.
116114
* `args`: Specifies any command-line arguments that are needed.
117115
* `cwd`: Specifies the current working directory for the launched `dotnet` process.
118-
* `stopAtEntry`: If set to true, the debugger will break at the entry point even when a breakpoint has not been set.
116+
* `stopAtEntry`: If set to `true`, the debugger will break at the entry point even when a breakpoint has not been set.
119117
* `console`: Set to `externalTerminal` to use external console windows rather than VS Code's built-in terminal. This is useful when running multiple NServiceBus endpoints.
120118

121119
### Web application
@@ -206,7 +204,7 @@ This example shows an entire **launch.json** file with **Sales** and **Billing**
206204
"type": "coreclr",
207205
"request": "launch",
208206
"preLaunchTask": "build",
209-
"program": "${workspaceFolder}/src/Billing/bin/Debug/net5.0/Billing.dll",
207+
"program": "${workspaceFolder}/src/Billing/bin/Debug/net9.0/Billing.dll",
210208
"args": [],
211209
"cwd": "${workspaceFolder}/src/Billing",
212210
"stopAtEntry": true,
@@ -217,7 +215,7 @@ This example shows an entire **launch.json** file with **Sales** and **Billing**
217215
"type": "coreclr",
218216
"request": "launch",
219217
"preLaunchTask": "build",
220-
"program": "${workspaceFolder}/src/Sales/bin/Debug/net5.0/Sales.dll",
218+
"program": "${workspaceFolder}/src/Sales/bin/Debug/net9.0/Sales.dll",
221219
"args": [],
222220
"cwd": "${workspaceFolder}/src/Sales",
223221
"stopAtEntry": false,
@@ -228,7 +226,7 @@ This example shows an entire **launch.json** file with **Sales** and **Billing**
228226
"type": "coreclr",
229227
"request": "launch",
230228
"preLaunchTask": "build",
231-
"program": "${workspaceFolder}/src/Website/bin/Debug/net5.0/Website.dll",
229+
"program": "${workspaceFolder}/src/Website/bin/Debug/net9.0/Website.dll",
232230
"args": [],
233231
"cwd": "${workspaceFolder}/src/Website",
234232
"stopAtEntry": false,
@@ -260,7 +258,7 @@ This example shows an entire **launch.json** file with **Sales** and **Billing**
260258
"request": "attach",
261259
"processId": "${command:pickProcess}"
262260
}
263-
,],
261+
],
264262
"compounds": [
265263
{
266264
"name": "Debug All",
@@ -278,5 +276,5 @@ This example shows an entire **launch.json** file with **Sales** and **Billing**
278276

279277
See the following articles for more information on debugging with VS Code:
280278

281-
* [OmniSharp: Configuring launch.json for C# debugging](https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md)
282-
* [Visual Studio Code: Integrate with External Tools via Tasks](https://code.visualstudio.com/docs/editor/tasks)
279+
* [Configuring C# debugging](https://code.visualstudio.com/docs/csharp/debugger-settings)
280+
* [Integrate with External Tools via Tasks](https://code.visualstudio.com/docs/editor/tasks)

0 commit comments

Comments
 (0)