diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 9eb91fa082..82b9df2845 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -191,6 +191,9 @@ "Fix All: ": "Fix All: ", "Pick a fix all scope": "Pick a fix all scope", "Fix All Code Action": "Fix All Code Action", + "No": "No", + ".NET: Generate Assets for Build and Debug": ".NET: Generate Assets for Build and Debug", + "The '{0}' command is not reccomended to be used when C# Dev Kit extension is installed. Would you like build and debug using a dynamic configuration instead?": "The '{0}' command is not reccomended to be used when C# Dev Kit extension is installed. Would you like build and debug using a dynamic configuration instead?", "Failed to set extension directory": "Failed to set extension directory", "Failed to set debugadpter directory": "Failed to set debugadpter directory", "Failed to set install complete file path": "Failed to set install complete file path", diff --git a/package.json b/package.json index d55402c5e8..877ab1de5f 100644 --- a/package.json +++ b/package.json @@ -1828,7 +1828,7 @@ "command": "dotnet.generateAssets", "title": "%command.dotnet.generateAssets.currentProject%", "category": ".NET", - "enablement": "dotnet.server.activationContext == 'Roslyn' || dotnet.server.activationContext == 'OmniSharp'" + "enablement": "dotnet.server.activationContext == 'RoslynDevKit' || dotnet.server.activationContext == 'Roslyn' || dotnet.server.activationContext == 'OmniSharp'" }, { "command": "dotnet.restore.project", diff --git a/src/lsptoolshost/debugger/debugger.ts b/src/lsptoolshost/debugger/debugger.ts index 01c5b6d2c3..79e706847c 100644 --- a/src/lsptoolshost/debugger/debugger.ts +++ b/src/lsptoolshost/debugger/debugger.ts @@ -51,9 +51,59 @@ export function registerDebugger( context.subscriptions.push( vscode.debug.registerDebugConfigurationProvider('coreclr', dotnetWorkspaceConfigurationProvider) ); + context.subscriptions.push( - vscode.commands.registerCommand('dotnet.generateAssets', async (selectedIndex) => - generateAssets(workspaceInformationProvider, selectedIndex) - ) + vscode.commands.registerCommand('dotnet.generateAssets', async (selectedIndex) => { + if (!(await promptForDevKitDebugConfigurations())) { + return; + } + + await generateAssets(workspaceInformationProvider, selectedIndex); + }) ); } + +async function promptForDevKitDebugConfigurations(): Promise { + if (getCSharpDevKit()) { + let result: boolean | undefined = undefined; + + while (result === undefined) { + const labelYes = vscode.l10n.t('Yes'); + const labelNo = vscode.l10n.t('No'); + const labelMoreInfo = vscode.l10n.t('More Information'); + const title: string = vscode.l10n.t('.NET: Generate Assets for Build and Debug'); + + const dialogResult = await vscode.window.showInformationMessage( + title, + { + modal: true, + detail: vscode.l10n.t( + `The '{0}' command is not recommended to be used when C# Dev Kit extension is installed. Would you like build and debug using a dynamic configuration instead?`, + title + ), + }, + labelYes, + labelNo, + labelMoreInfo + ); + + if (dialogResult === labelYes) { + await vscode.commands.executeCommand('workbench.action.debug.selectandstart', 'dotnet'); + result = false; + } else if (dialogResult === labelNo) { + // User cancelled dialog and wishes to continue generating assets. + result = true; + } else if (dialogResult === labelMoreInfo) { + const launchjsonDescriptionURL = 'https://aka.ms/VSCode-CS-DynamicDebugConfig'; + await vscode.env.openExternal(vscode.Uri.parse(launchjsonDescriptionURL)); + } else if (dialogResult === undefined) { + // Do nothing, user closed the dialog. + result = false; + } + } + + return result; + } + + return false; +}