Skip to content

Commit adf9959

Browse files
authored
Merge pull request #6620 from microsoft/seanmcm/cherryPick6619
cherry pick6619
2 parents a3de2f9 + 52fe795 commit adf9959

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Extension/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Fix various task variables not getting resolved with `cppbuild` tasks. [#6538](https://github.com/microsoft/vscode-cpptools/issues/6538)
88
* Fix warnings not appearing with `cppbuild` tasks. [#6556](https://github.com/microsoft/vscode-cpptools/issues/6556)
99
* Fix endless CPU/memory usage if the cpptools process crashes. [#6603](https://github.com/microsoft/vscode-cpptools/issues/6603)
10+
* Fix the default `cwd` for `cppbuild` tasks. [#6618](https://github.com/microsoft/vscode-cpptools/issues/6618)
1011

1112
## Version 1.1.2: November 17, 2020
1213
### Bug Fix

Extension/src/Debugger/configurationProvider.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,13 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
178178
newConfig.preLaunchTask = task.name;
179179
newConfig.externalConsole = false;
180180
const exeName: string = path.join("${fileDirname}", "${fileBasenameNoExtension}");
181-
newConfig.program = platform === "win32" ? exeName + ".exe" : exeName;
181+
const isWindows: boolean = platform === 'win32';
182+
newConfig.program = isWindows ? exeName + ".exe" : exeName;
182183
// Add the "detail" property to show the compiler path in QuickPickItem.
183184
// This property will be removed before writing the DebugConfiguration in launch.json.
184185
newConfig.detail = task.detail ? task.detail : definition.command;
186+
const isCl: boolean = compilerName === "cl.exe";
187+
newConfig.cwd = isWindows && !isCl && !process.env.PATH?.includes(compilerPath) ? path.dirname(compilerPath) : "${workspaceFolder}";
185188

186189
return new Promise<vscode.DebugConfiguration>(resolve => {
187190
if (platform === "darwin") {
@@ -201,7 +204,7 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
201204
debuggerName = "gdb";
202205
}
203206

204-
if (platform === "win32") {
207+
if (isWindows) {
205208
debuggerName += ".exe";
206209
}
207210

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export class CppBuildTaskProvider implements TaskProvider {
167167
if (compilerArgs && compilerArgs.length > 0) {
168168
args = args.concat(compilerArgs);
169169
}
170-
const cwd: string = isCl ? "${workspaceFolder}" : path.dirname(compilerPath);
170+
const cwd: string = isWindows && !isCl && !process.env.PATH?.includes(compilerPath) ? path.dirname(compilerPath) : "${workspaceFolder}";
171171
const options: cp.ExecOptions | undefined = { cwd: cwd };
172172
definition = {
173173
type: CppBuildTaskProvider.CppBuildScriptType,

0 commit comments

Comments
 (0)