You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add 'walkthrough' to debugger settings
The current C# debugger-settings.md is mostly a long list of options without a walkthrough first to better guide users on how to use launchSettings.json. This PR:
1. Adds a walkthrough so this is hopefully more understandable.
2. Moves the 'Configuring launchSettings.json file' up to the top after the walkthrough
3. Clarifies the 'launchSettings.json support' section, since we didn't do a great job there explaining those options were for `coreclr`/`clr`
These changes are based on feedback in dotnet/vscode-csharp#8184
* Apply suggestions from code review
Co-authored-by: Nick Trogh <[email protected]>
---------
Co-authored-by: Nick Trogh <[email protected]>
You can configure the C# debugger in Visual Studio Code with a `launch.json`, `launchSettings.json`, or your user `settings.json` file.
12
12
13
-
Below are common options you may want to change while debugging.
13
+
## Walkthrough: setting command-line arguments
14
+
15
+
Before we get into the details of all the possible options, let's walk through a basic scenario: setting command-line arguments to your program. These steps also work for updating other basic options like environment variables or the current working directory.
16
+
17
+
### Approach 1: `launchSettings.json`
18
+
19
+
For C# Dev Kit, the recommended way to debug is to let C# Dev Kit automatically figure out how to debug from settings in the project file. This means that you either don't have a `<workspace_root>/.vscode/launch.json` file, or if you have one, you have `"type": "dotnet"` set for the active configuration. For command-line arguments, "figure out from the project file" means to pull the value from `<Project-Directory>/Propeties/launchSettings.json`. The advantage of `launchSettings.json` is that it allows settings to be shared between Visual Studio Code, full Visual Studio, and `dotnet run`.
20
+
21
+
For this case, here are the steps to set the command-line arguments:
22
+
1. In workspace Explorer view, navigate to the directory of the project (.csproj file) you want to launch
23
+
2. If there isn't a `Properties` directory already, create it
24
+
3. If there isn't a `launchSettings.json` file already, create one, you can use the below text as an example
25
+
4. Change the `commandLineArgs` property to what you would like the command-line arguments to be
If you are using the `coreclr` or `clr` debug adapter type in VS Code, command-line arguments are stored in your `<workspace_root>/.vscode/launch.json`. To edit them in this case:
42
+
43
+
1. Open up `<workspace_root>/.vscode/launch.json`
44
+
2. Find the `coreclr` or `clr` launch configuration you want to launch
45
+
3. Edit the `args` property. This can either be a string, or an array of strings
46
+
47
+
## Configuring launchSettings.json
14
48
15
-
## Configuring VS Code's debugging behavior
49
+
With C# Dev Kit, you can bring your `launchSettings.json` from Visual Studio to work with Visual Studio Code
*`commandLineArgs` - The arguments to pass to the target being run.
107
+
*`executablePath` - An absolute or relative path to the executable.
108
+
*`workingDirectory` - Sets the working directory of the command.
109
+
*`launchBrowser` - Set to `true` if the browser should be launched.
110
+
*`applicationUrl` - A semi-colon delimited list of URL(s) to configure for the web server.
111
+
*`sslPort` - The SSL port to use for the web site.
112
+
*`httpPort` - The HTTP port to use for the web site.
113
+
114
+
# List of configurable options
115
+
116
+
Below are common options you may want to change while debugging.
117
+
118
+
## PreLaunchTask
18
119
19
120
The `preLaunchTask` field runs the associated taskName in `tasks.json` before debugging your program. You can get the default build prelaunch task by executing the command **Tasks: Configure Tasks Runner** from the VS Code Command Palette.
20
121
@@ -194,9 +295,9 @@ Example:
194
295
195
296

196
297
197
-
## launchSettings.json support
298
+
## `launchSettingsProfile` and `launchSettingsFilePath`
198
299
199
-
In addition to `launch.json`, launch options can be configured through a `launchSettings.json` file. The advantage of `launchSettings.json` is that it allows settings to be shared between Visual Studio Code, full Visual Studio, and `dotnet run`.
300
+
While full support for `launchSettings.json` requires use of a launch configuration with `"type": "dotnet"`, the `coreclr` and `clr` debugger types also support a limited subset of `launchSettings.json`functionality. This is useful for users who want to use the same settings in both Visual Studio Code and full Visual Studio.
200
301
201
302
To configure which `launchSettings.json` profile to use (or to prevent it from being used), set the `launchSettingsProfile` option:
202
303
@@ -221,9 +322,9 @@ Which would then, for example, use `myVariableName` from this example `launchSet
221
322
222
323
If `launchSettingsProfile` is NOT specified, the first profile with `"commandName": "Project"` will be used.
223
324
224
-
If `launchSettingsProfile` is set to null/an empty string, then Properties/launchSettings.json will be ignored.
325
+
If `launchSettingsProfile` is set to null/an empty string, then `Properties/launchSettings.json` will be ignored.
225
326
226
-
By default, the debugger will search for `launchSettings.json` in {cwd}/Properties/launchSettings.json. To customize this path, set `launchSettingsFilePath`:
327
+
By default, the debugger will search for `launchSettings.json` in `{cwd}/Properties/launchSettings.json`. To customize this path, set `launchSettingsFilePath`:
0 commit comments