From 90439a6d0975b21101965d83653f4b471c06db2b Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 13 Nov 2024 10:24:09 -0800 Subject: [PATCH] Don't use `getCompiledProjectInfo` in `pickProcess` (#4333) * Skip test to let artifacts publish * Fix stupid build issue * Fix for .NET debugging * Remove export moniker * Remove changes to global.test. --- src/commands/pickFuncProcess.ts | 9 +++------ src/funcCoreTools/funcHostTask.ts | 4 +--- src/workspace/listLocalProjects.ts | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/commands/pickFuncProcess.ts b/src/commands/pickFuncProcess.ts index 74f8f2005..5eb61a393 100644 --- a/src/commands/pickFuncProcess.ts +++ b/src/commands/pickFuncProcess.ts @@ -7,7 +7,7 @@ import { sendRequestWithTimeout, type AzExtRequestPrepareOptions } from '@micros import { callWithTelemetryAndErrorHandling, parseError, UserCancelledError, type IActionContext } from '@microsoft/vscode-azext-utils'; import * as unixPsTree from 'ps-tree'; import * as vscode from 'vscode'; -import { hostStartTaskName, ProjectLanguage } from '../constants'; +import { hostStartTaskName } from '../constants'; import { preDebugValidate, type IPreDebugValidateResult } from '../debug/validatePreDebug'; import { ext } from '../extensionVariables'; import { buildPathToWorkspaceFolderMap, getFuncPortFromTaskOrProject, isFuncHostTask, runningFuncTaskMap, stopFuncTaskIfRunning, type IRunningFuncTask } from '../funcCoreTools/funcHostTask'; @@ -17,7 +17,6 @@ import { requestUtils } from '../utils/requestUtils'; import { taskUtils } from '../utils/taskUtils'; import { getWindowsProcessTree, ProcessDataFlag, type IProcessInfo, type IWindowsProcessTree } from '../utils/windowsProcessTree'; import { getWorkspaceSetting } from '../vsCodeConfig/settings'; -import { getCompiledProjectInfo } from '../workspace/listLocalProjects'; const funcTaskReadyEmitter = new vscode.EventEmitter(); export const onDotnetFuncTaskReady = funcTaskReadyEmitter.event; @@ -82,10 +81,6 @@ export async function pickFuncProcess(context: IActionContext, debugConfig: vsco throw new UserCancelledError('preDebugValidate'); } - const projectInfo = await getCompiledProjectInfo(context, result.workspace.uri.fsPath, ProjectLanguage.CSharp); - const buildPath: string = projectInfo?.compiledProjectPath || result.workspace.uri.fsPath; - await waitForPrevFuncTaskToStop(result.workspace, buildPath); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const preLaunchTaskName: string | undefined = debugConfig.preLaunchTask; const tasks: vscode.Task[] = await vscode.tasks.fetchTasks(); @@ -97,6 +92,8 @@ export async function pickFuncProcess(context: IActionContext, debugConfig: vsco throw new Error(localize('noFuncTask', 'Failed to find "{0}" task.', preLaunchTaskName || hostStartTaskName)); } + const buildPath: string = (funcTask.execution as vscode.ShellExecution)?.options?.cwd || result.workspace.uri.fsPath; + await waitForPrevFuncTaskToStop(result.workspace, buildPath); const taskInfo = await startFuncTask(context, result.workspace, buildPath, funcTask); return await pickChildProcess(taskInfo); } diff --git a/src/funcCoreTools/funcHostTask.ts b/src/funcCoreTools/funcHostTask.ts index d1093d2fc..9d4629665 100644 --- a/src/funcCoreTools/funcHostTask.ts +++ b/src/funcCoreTools/funcHostTask.ts @@ -140,9 +140,7 @@ export function stopFuncTaskIfRunning(workspaceFolder: vscode.WorkspaceFolder | runningFuncTask = [runningFuncTaskMap.get(workspaceFolder, buildPath)]; } - if (runningFuncTask !== undefined) { - - + if (runningFuncTask !== undefined && runningFuncTask.length > 0) { for (const runningFuncTaskItem of runningFuncTask) { if (!runningFuncTaskItem) break; if (terminate) { diff --git a/src/workspace/listLocalProjects.ts b/src/workspace/listLocalProjects.ts index 096bc2969..8362bd034 100644 --- a/src/workspace/listLocalProjects.ts +++ b/src/workspace/listLocalProjects.ts @@ -92,7 +92,7 @@ export async function listLocalProjects(): Promise { type CompiledProjectInfo = { compiledProjectPath: string; isIsolated: boolean }; -export async function getCompiledProjectInfo(context: IActionContext, projectPath: string, projectLanguage: ProjectLanguage): Promise { +async function getCompiledProjectInfo(context: IActionContext, projectPath: string, projectLanguage: ProjectLanguage): Promise { if (projectLanguage === ProjectLanguage.CSharp || projectLanguage === ProjectLanguage.FSharp) { const projFiles: dotnetUtils.ProjectFile[] = await dotnetUtils.getProjFiles(context, projectLanguage, projectPath); if (projFiles.length === 1) {