Skip to content

Commit ffd39c3

Browse files
authored
Prompt user to install func cli before debugging (#957)
And remove prompt after creating project
1 parent 9d6a5db commit ffd39c3

File tree

7 files changed

+31
-54
lines changed

7 files changed

+31
-54
lines changed

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -765,11 +765,6 @@
765765
"description": "%azFunc.pickProcessTimeoutDescription%",
766766
"default": 60
767767
},
768-
"azureFunctions.showFuncInstallation": {
769-
"type": "boolean",
770-
"description": "%azFunc.showFuncInstallationDescription%",
771-
"default": true
772-
},
773768
"azureFunctions.templateVersion": {
774769
"type": "string",
775770
"description": "%azFunc.templateVersion%"

package.nls.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"azFunc.enableRemoteDebugging": "Enable remote debugging, an experimental feature that only supports Java-based Functions Apps.",
4242
"azFunc.deleteProxy": "Delete Proxy...",
4343
"azFunc.pickProcessTimeoutDescription": "The timeout (in seconds) to be used when searching for the Azure Functions host process. Since a build is required every time you F5, you may need to adjust this based on how long your build takes.",
44-
"azFunc.showFuncInstallationDescription": "Show a warning to install Azure Functions Core Tools CLI when you create a new project if the CLI is not installed.",
4544
"azFunc.templateVersion": "A runtime release version (any runtime) that species which templates will be used rather than the latest templates. This version will be used for ALL runtimes. (Requires a restart of VS Code to take effect)",
4645
"azFunc.projectOpenBehaviorDescription": "The behavior to use after creating a new project. The options are \"AddToWorkspace\", \"OpenInNewWindow\", or \"OpenInCurrentWindow\".",
4746
"azFunc.uninstallFuncCoreTools": "Uninstall Azure Functions Core Tools",

src/commands/createNewProject/PythonProjectCreator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class PythonProjectCreator extends ScriptProjectCreatorBase {
5353

5454
public async onCreateNewProject(): Promise<void> {
5555
const funcCoreRequired: string = localize('funcCoreRequired', 'Azure Functions Core Tools must be installed to create, debug, and deploy local Python Functions projects.');
56-
if (!await validateFuncCoreToolsInstalled(true /* forcePrompt */, funcCoreRequired)) {
56+
if (!await validateFuncCoreToolsInstalled(funcCoreRequired)) {
5757
throw new UserCancelledError();
5858
}
5959

src/commands/createNewProject/createNewProject.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { IActionContext } from 'vscode-azureextensionui';
99
import { ProjectLanguage, projectLanguageSetting, ProjectRuntime } from '../../constants';
1010
import { ext } from '../../extensionVariables';
1111
import { addLocalFuncTelemetry } from '../../funcCoreTools/getLocalFuncCoreToolsVersion';
12-
import { validateFuncCoreToolsInstalled } from '../../funcCoreTools/validateFuncCoreToolsInstalled';
1312
import { localize } from '../../localize';
1413
import { convertStringToRuntime, getGlobalFuncExtensionSetting } from '../../ProjectSettings';
1514
import { gitUtils } from '../../utils/gitUtils';
@@ -80,10 +79,6 @@ export async function createNewProject(
8079
// don't wait
8180
window.showInformationMessage(localize('finishedCreating', 'Finished creating project.'));
8281

83-
// don't wait
84-
// tslint:disable-next-line:no-floating-promises
85-
validateFuncCoreToolsInstalled();
86-
8782
if (openFolder) {
8883
await workspaceUtil.ensureFolderIsOpen(functionAppPath, actionContext);
8984
}

src/commands/pickFuncProcess.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getFuncExtensionSetting } from '../ProjectSettings';
1414
import { getWindowsProcessTree, IProcessTreeNode, IWindowsProcessTree } from '../utils/windowsProcessTree';
1515

1616
export async function pickFuncProcess(this: IActionContext): Promise<string | undefined> {
17-
if (!await validateFuncCoreToolsInstalled(true /* forcePrompt */)) {
17+
if (!await validateFuncCoreToolsInstalled()) {
1818
throw new UserCancelledError();
1919
}
2020

src/debug/FuncDebugProviderBase.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import { CancellationToken, DebugConfiguration, DebugConfigurationProvider, ShellExecution, WorkspaceFolder } from 'vscode';
77
import { isFunctionProject } from '../commands/createNewProject/isFunctionProject';
8+
import { hostStartTaskName } from '../constants';
9+
import { validateFuncCoreToolsInstalled } from '../funcCoreTools/validateFuncCoreToolsInstalled';
810

911
export abstract class FuncDebugProviderBase implements DebugConfigurationProvider {
1012
protected abstract defaultPort: number;
@@ -25,8 +27,14 @@ export abstract class FuncDebugProviderBase implements DebugConfigurationProvide
2527
return result;
2628
}
2729

28-
public async resolveDebugConfiguration?(folder: WorkspaceFolder | undefined, debugConfiguration: DebugConfiguration, _token?: CancellationToken): Promise<DebugConfiguration> {
30+
public async resolveDebugConfiguration(folder: WorkspaceFolder | undefined, debugConfiguration: DebugConfiguration, _token?: CancellationToken): Promise<DebugConfiguration | undefined> {
2931
this._debugPorts.set(folder, <number | undefined>debugConfiguration.port);
32+
if (debugConfiguration.preLaunchTask === hostStartTaskName) {
33+
if (!await validateFuncCoreToolsInstalled()) {
34+
return undefined;
35+
}
36+
}
37+
3038
return debugConfiguration;
3139
}
3240

src/funcCoreTools/validateFuncCoreToolsInstalled.ts

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,61 +10,41 @@ import { callWithTelemetryAndErrorHandling, DialogResponses, IActionContext } fr
1010
import { PackageManager } from '../constants';
1111
import { ext } from '../extensionVariables';
1212
import { localize } from '../localize';
13-
import { getFuncExtensionSetting, updateGlobalSetting } from '../ProjectSettings';
1413
import { cpUtils } from '../utils/cpUtils';
1514
import { getFuncPackageManager } from './getFuncPackageManager';
1615
import { installFuncCoreTools } from './installFuncCoreTools';
1716

18-
export async function validateFuncCoreToolsInstalled(forcePrompt: boolean = false, customMessage?: string): Promise<boolean> {
17+
export async function validateFuncCoreToolsInstalled(customMessage?: string): Promise<boolean> {
1918
let input: MessageItem | undefined;
2019
let installed: boolean = false;
2120
const install: MessageItem = { title: localize('install', 'Install') };
2221

2322
await callWithTelemetryAndErrorHandling('azureFunctions.validateFuncCoreToolsInstalled', async function (this: IActionContext): Promise<void> {
2423
this.suppressErrorDisplay = true;
25-
this.properties.forcePrompt = String(forcePrompt);
2624

27-
const settingKey: string = 'showFuncInstallation';
28-
if (forcePrompt || getFuncExtensionSetting<boolean>(settingKey)) {
29-
if (await funcToolsInstalled()) {
30-
installed = true;
25+
if (await funcToolsInstalled()) {
26+
installed = true;
27+
} else {
28+
const items: MessageItem[] = [];
29+
const message: string = customMessage ? customMessage : localize('installFuncTools', 'You must have the Azure Functions Core Tools installed to debug your local functions.');
30+
const packageManager: PackageManager | undefined = await getFuncPackageManager(false /* isFuncInstalled */);
31+
if (packageManager !== undefined) {
32+
items.push(install);
3133
} else {
32-
const items: MessageItem[] = [];
33-
const message: string = customMessage ? customMessage : localize('installFuncTools', 'You must have the Azure Functions Core Tools installed to debug your local functions.');
34-
const packageManager: PackageManager | undefined = await getFuncPackageManager(false /* isFuncInstalled */);
35-
if (packageManager !== undefined) {
36-
items.push(install);
37-
if (!forcePrompt) {
38-
items.push(DialogResponses.skipForNow);
39-
} else {
40-
items.push(DialogResponses.cancel);
41-
}
42-
} else {
43-
items.push(DialogResponses.learnMore);
44-
}
45-
46-
if (!forcePrompt) {
47-
items.push(DialogResponses.dontWarnAgain);
48-
}
34+
items.push(DialogResponses.learnMore);
35+
}
4936

50-
if (forcePrompt) {
51-
// See issue: https://github.com/Microsoft/vscode-azurefunctions/issues/535
52-
input = await ext.ui.showWarningMessage(message, { modal: true }, ...items);
53-
} else {
54-
input = await ext.ui.showWarningMessage(message, ...items);
55-
}
37+
// See issue: https://github.com/Microsoft/vscode-azurefunctions/issues/535
38+
input = await ext.ui.showWarningMessage(message, { modal: true }, ...items);
5639

57-
this.properties.dialogResult = input.title;
40+
this.properties.dialogResult = input.title;
5841

59-
if (input === install) {
60-
// tslint:disable-next-line:no-non-null-assertion
61-
await installFuncCoreTools(packageManager!);
62-
installed = true;
63-
} else if (input === DialogResponses.dontWarnAgain) {
64-
await updateGlobalSetting(settingKey, false);
65-
} else if (input === DialogResponses.learnMore) {
66-
await opn('https://aka.ms/Dqur4e');
67-
}
42+
if (input === install) {
43+
// tslint:disable-next-line:no-non-null-assertion
44+
await installFuncCoreTools(packageManager!);
45+
installed = true;
46+
} else if (input === DialogResponses.learnMore) {
47+
await opn('https://aka.ms/Dqur4e');
6848
}
6949
}
7050
});

0 commit comments

Comments
 (0)