Skip to content

Support showing Generate Build and Debug assets for CDK #8169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
56 changes: 53 additions & 3 deletions src/lsptoolshost/debugger/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
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;
}
Loading