Skip to content

Commit 95aaffd

Browse files
authored
Add suppressDotnetInstallWarning user setting (#700)
- Add a user option to suppress the "Get .NET CLI tools" popup that appears when the tools are not found. - Add a navigation point to the settings page to the popup. Fix for #603.
1 parent e7a4d92 commit 95aaffd

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@
7070
"configuration": "./csharp.configuration.json"
7171
}
7272
],
73+
"configuration": {
74+
"title": "C# configuration",
75+
"properties": {
76+
"csharp.suppressDotnetInstallWarning": {
77+
"type": "boolean",
78+
"default": false,
79+
"description": "Suppress the warning that the .NET CLI is not on the path."
80+
}
81+
}
82+
},
7383
"grammars": [
7484
{
7585
"language": "csharp",

src/coreclr-debug/activate.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,22 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe
9090
_util.closeInstallLog();
9191
});
9292
}).catch(() => {
93-
const getDotNetMessage = "Get .NET CLI tools";
94-
vscode.window.showErrorMessage("The .NET CLI tools cannot be located. .NET Core debugging will not be enabled. Make sure .NET CLI tools are installed and are on the path.",
95-
getDotNetMessage).then(value => {
96-
if (value === getDotNetMessage) {
97-
let open = require('open');
98-
open("https://www.microsoft.com/net/core");
99-
}
100-
});
93+
const config = vscode.workspace.getConfiguration('csharp');
94+
if (!config.get('suppressDotnetInstallWarning', false)) {
95+
const getDotNetMessage = 'Get .NET CLI tools';
96+
const goToSettingsMessage = 'Disable this message in user settings';
97+
// Buttons are shown in right-to-left order, with a close button to the right of everything;
98+
// getDotNetMessage will be the first button, then goToSettingsMessage, then the close button.
99+
vscode.window.showErrorMessage('The .NET CLI tools cannot be located. .NET Core debugging will not be enabled. Make sure .NET CLI tools are installed and are on the path.',
100+
goToSettingsMessage, getDotNetMessage).then(value => {
101+
if (value === getDotNetMessage) {
102+
let open = require('open');
103+
open('https://www.microsoft.com/net/core');
104+
} else if (value === goToSettingsMessage) {
105+
vscode.commands.executeCommand('workbench.action.openGlobalSettings');
106+
}
107+
});
108+
}
101109
});
102110
}
103111

0 commit comments

Comments
 (0)