Skip to content

Commit e45f208

Browse files
WardenGnawCopilot
andauthored
Support showing Generate Build and Debug assets for CDK (#8169)
Co-authored-by: Copilot <[email protected]>
1 parent 09fdc5f commit e45f208

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed

l10n/bundle.l10n.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@
192192
"Fix All: ": "Fix All: ",
193193
"Pick a fix all scope": "Pick a fix all scope",
194194
"Fix All Code Action": "Fix All Code Action",
195+
"No": "No",
196+
".NET: Generate Assets for Build and Debug": ".NET: Generate Assets for Build and Debug",
197+
"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?",
195198
"Failed to set extension directory": "Failed to set extension directory",
196199
"Failed to set debugadpter directory": "Failed to set debugadpter directory",
197200
"Failed to set install complete file path": "Failed to set install complete file path",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1845,7 +1845,7 @@
18451845
"command": "dotnet.generateAssets",
18461846
"title": "%command.dotnet.generateAssets.currentProject%",
18471847
"category": ".NET",
1848-
"enablement": "dotnet.server.activationContext == 'Roslyn' || dotnet.server.activationContext == 'OmniSharp'"
1848+
"enablement": "dotnet.server.activationContext == 'RoslynDevKit' || dotnet.server.activationContext == 'Roslyn' || dotnet.server.activationContext == 'OmniSharp'"
18491849
},
18501850
{
18511851
"command": "dotnet.restore.project",

src/lsptoolshost/debugger/debugger.ts

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,59 @@ export function registerDebugger(
5151
context.subscriptions.push(
5252
vscode.debug.registerDebugConfigurationProvider('coreclr', dotnetWorkspaceConfigurationProvider)
5353
);
54+
5455
context.subscriptions.push(
55-
vscode.commands.registerCommand('dotnet.generateAssets', async (selectedIndex) =>
56-
generateAssets(workspaceInformationProvider, selectedIndex)
57-
)
56+
vscode.commands.registerCommand('dotnet.generateAssets', async (selectedIndex) => {
57+
if (!(await promptForDevKitDebugConfigurations())) {
58+
return;
59+
}
60+
61+
await generateAssets(workspaceInformationProvider, selectedIndex);
62+
})
5863
);
5964
}
65+
66+
async function promptForDevKitDebugConfigurations(): Promise<boolean> {
67+
if (getCSharpDevKit()) {
68+
let result: boolean | undefined = undefined;
69+
70+
while (result === undefined) {
71+
const labelYes = vscode.l10n.t('Yes');
72+
const labelNo = vscode.l10n.t('No');
73+
const labelMoreInfo = vscode.l10n.t('More Information');
74+
const title: string = vscode.l10n.t('.NET: Generate Assets for Build and Debug');
75+
76+
const dialogResult = await vscode.window.showInformationMessage(
77+
title,
78+
{
79+
modal: true,
80+
detail: vscode.l10n.t(
81+
`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?`,
82+
title
83+
),
84+
},
85+
labelYes,
86+
labelNo,
87+
labelMoreInfo
88+
);
89+
90+
if (dialogResult === labelYes) {
91+
await vscode.commands.executeCommand('workbench.action.debug.selectandstart', 'dotnet');
92+
result = false;
93+
} else if (dialogResult === labelNo) {
94+
// User cancelled dialog and wishes to continue generating assets.
95+
result = true;
96+
} else if (dialogResult === labelMoreInfo) {
97+
const launchjsonDescriptionURL = 'https://aka.ms/VSCode-CS-DynamicDebugConfig';
98+
await vscode.env.openExternal(vscode.Uri.parse(launchjsonDescriptionURL));
99+
} else if (dialogResult === undefined) {
100+
// Do nothing, user closed the dialog.
101+
result = false;
102+
}
103+
}
104+
105+
return result;
106+
}
107+
108+
return false;
109+
}

0 commit comments

Comments
 (0)