Skip to content

Commit c32f17b

Browse files
launch.json fixes for 'cwd' and '${command.' (#1282)
This resolves: #1275 #1083
1 parent 74ecafc commit c32f17b

File tree

5 files changed

+27
-12
lines changed

5 files changed

+27
-12
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ There have been several fixes to the colorizer grammar resulting in much smoothe
241241

242242
* Support for Unity and Mono development on macOS and Linux has been restored! This release brings back support for the Mono version of OmniSharp, which is used to provide *much* better support for .csproj/.sln projects. Please note that Mono version 4.0.1 or newer is required.
243243
* Generation of tasks.json and launch.json files can now properly handle nested projects. [#170](https://github.com/OmniSharp/omnisharp-vscode/issues/170)
244-
* New UI that makes it easy to select a process ID when attaching the debugger to another process. Note: If you have an existing launch.json file, you can re-generate it by deleting the file, closing your workspace in Visual Studio Code and opening it again. Or, you can open the launch.json file and change the `processId` value to `"${command.pickProcess}"`.
244+
* New UI that makes it easy to select a process ID when attaching the debugger to another process. Note: If you have an existing launch.json file, you can re-generate it by deleting the file, closing your workspace in Visual Studio Code and opening it again. Or, you can open the launch.json file and change the `processId` value to `"${command:pickProcess}"`.
245245
* Support for debugging in .cshtml files. To enable this, add a `sourceFileMap` entry to your launch.json with the following content: `"sourceFileMap": { "/Views": "${workspaceRoot}/Views" }`
246246
* Support for conditional breakpoints
247247
* New support for changing variable values in the debugger! To try this, just right-click on the variable name and select 'Set Value'. Note: To properly support this feature, we've changed the display of variable type names in the debugger to a shortened form. The full type name can be viewed by hovering over the name with the mouse.

debugger.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ The C# debugger supports attaching to processes. To do this, switch to the Debug
136136

137137
![Debug launch configuration drop down](https://raw.githubusercontent.com/wiki/OmniSharp/omnisharp-vscode/images/debug-launch-configurations.png)
138138

139-
Select the '.NET Core Attach' configuration. Clicking the play button (or pressing <kbd>F5</kbd>) will then try to attach. In launch.json, if `processId` is set to `"${command.pickProcess}"` this will provide UI to select which process to attach to.
139+
Select the '.NET Core Attach' configuration. Clicking the play button (or pressing <kbd>F5</kbd>) will then try to attach. In launch.json, if `processId` is set to `"${command:pickProcess}"` this will provide UI to select which process to attach to.
140140

141141
#### Docker Support
142142

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -878,12 +878,12 @@
878878
"anyOf": [
879879
{
880880
"type": "string",
881-
"description": "The process id to attach to. Use \"${command.pickProcesss}\" to get a list of running processes to attach to. If 'processId' used, 'processName' should not be used.",
882-
"default": "${command.pickProcess}"
881+
"description": "The process id to attach to. Use \"${command:pickProcesss}\" to get a list of running processes to attach to. If 'processId' used, 'processName' should not be used.",
882+
"default": "${command:pickProcess}"
883883
},
884884
{
885885
"type": "integer",
886-
"description": "The process id to attach to. Use \"${command.pickProcesss}\" to get a list of running processes to attach to. If 'processId' used, 'processName' should not be used.",
886+
"description": "The process id to attach to. Use \"${command:pickProcesss}\" to get a list of running processes to attach to. If 'processId' used, 'processName' should not be used.",
887887
"default": 0
888888
}
889889
]
@@ -1162,7 +1162,7 @@
11621162
"name": ".NET Core Attach",
11631163
"type": "coreclr",
11641164
"request": "attach",
1165-
"processId": "${command.pickProcess}"
1165+
"processId": "${command:pickProcess}"
11661166
}
11671167
]
11681168
}

src/assets.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,21 @@ export class AssetGenerator {
179179
return result;
180180
}
181181

182+
private computeWorkingDirectory() : string {
183+
if (!this.hasProject) {
184+
// If there's no target project data, use a placeholder for the path.
185+
return '${workspaceRoot}';
186+
}
187+
188+
let result = '${workspaceRoot}';
189+
190+
if (this.projectPath) {
191+
result = path.join(result, path.relative(this.rootPath, this.projectPath));
192+
}
193+
194+
return result;
195+
}
196+
182197
private createLaunchConfiguration(): ConsoleLaunchConfiguration {
183198
return {
184199
name: '.NET Core Launch (console)',
@@ -187,7 +202,7 @@ export class AssetGenerator {
187202
preLaunchTask: 'build',
188203
program: this.computeProgramPath(),
189204
args: [],
190-
cwd: '${workspaceRoot}',
205+
cwd: this.computeWorkingDirectory(),
191206
console: "internalConsole",
192207
stopAtEntry: false,
193208
internalConsoleOptions: "openOnSessionStart"
@@ -202,7 +217,7 @@ export class AssetGenerator {
202217
preLaunchTask: 'build',
203218
program: this.computeProgramPath(),
204219
args: [],
205-
cwd: '${workspaceRoot}',
220+
cwd: this.computeWorkingDirectory(),
206221
stopAtEntry: false,
207222
internalConsoleOptions: "openOnSessionStart",
208223
launchBrowser: {
@@ -233,7 +248,7 @@ export class AssetGenerator {
233248
name: '.NET Core Attach',
234249
type: 'coreclr',
235250
request: 'attach',
236-
processId: "${command.pickProcess}"
251+
processId: "${command:pickProcess}"
237252
};
238253
}
239254

src/tools/OptionsSchema.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,12 @@
345345
"anyOf": [
346346
{
347347
"type": "string",
348-
"description": "The process id to attach to. Use \"${command.pickProcesss}\" to get a list of running processes to attach to. If 'processId' used, 'processName' should not be used.",
349-
"default": "${command.pickProcess}"
348+
"description": "The process id to attach to. Use \"${command:pickProcesss}\" to get a list of running processes to attach to. If 'processId' used, 'processName' should not be used.",
349+
"default": "${command:pickProcess}"
350350
},
351351
{
352352
"type": "integer",
353-
"description": "The process id to attach to. Use \"${command.pickProcesss}\" to get a list of running processes to attach to. If 'processId' used, 'processName' should not be used.",
353+
"description": "The process id to attach to. Use \"${command:pickProcesss}\" to get a list of running processes to attach to. If 'processId' used, 'processName' should not be used.",
354354
"default": 0
355355
}
356356
]

0 commit comments

Comments
 (0)