Skip to content

Commit f873cfc

Browse files
committed
show help page if dotnet sdk version is insufficient
1 parent b8bae3a commit f873cfc

File tree

5 files changed

+52
-8
lines changed

5 files changed

+52
-8
lines changed

src/dotnet-interactive-vscode-common/src/extension.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
import * as contracts from './dotnet-interactive/contracts';
5+
import * as helpService from './helpService';
56
import * as fs from 'fs';
67
import * as os from 'os';
78
import * as path from 'path';
@@ -87,17 +88,23 @@ export async function activate(context: vscode.ExtensionContext) {
8788
registerAcquisitionCommands(context, diagnosticsChannel);
8889

8990
// check sdk version
91+
let showHelpPage = false;
9092
try {
9193
const dotnetVersion = await getDotNetVersionOrThrow(DotNetPathManager.getDotNetPath(), diagnosticsChannel);
9294
if (!isVersionSufficient(dotnetVersion, minDotNetSdkVersion)) {
95+
showHelpPage = true;
9396
const message = `The .NET SDK version ${dotnetVersion} is not sufficient. The minimum required version is ${minDotNetSdkVersion}.`;
9497
diagnosticsChannel.appendLine(message);
9598
vscode.window.showErrorMessage(message);
96-
throw new Error(message);
9799
}
98100
} catch (e) {
101+
showHelpPage = true;
99102
vscode.window.showErrorMessage(`Please install the .NET SDK version ${minDotNetSdkVersion} from https://dotnet.microsoft.com/en-us/download`);
100-
throw e;
103+
}
104+
105+
if (showHelpPage) {
106+
const helpServiceInstance = new helpService.HelpService(context);
107+
await helpServiceInstance.showHelpPageAndThrow(helpService.DotNetVersion);
101108
}
102109

103110
async function kernelChannelCreator(notebookUri: vscodeLike.Uri): Promise<KernelCommandAndEventChannel> {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
import * as path from 'path';
5+
import * as vscode from 'vscode';
6+
7+
export const DotNetVersion = 'DotNetVersion';
8+
9+
export type HelpPage =
10+
typeof DotNetVersion;
11+
12+
export class HelpService {
13+
constructor(private readonly context: vscode.ExtensionContext) {
14+
}
15+
16+
async showHelpPageAndThrow(page: HelpPage): Promise<void> {
17+
const helpPagePath = getHelpPagePath(this.context, page);
18+
const helpPageUri = vscode.Uri.file(helpPagePath);
19+
await vscode.commands.executeCommand('markdown.showPreview', helpPageUri);
20+
throw new Error('Error activating extension, see the displayed help page for more details.');
21+
}
22+
}
23+
24+
function getHelpPagePath(context: vscode.ExtensionContext, page: HelpPage) {
25+
const basePath = path.join(context.extensionPath, 'help');
26+
const helpPagePath = path.join(basePath, `${page}.md`);
27+
return helpPagePath;
28+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Install supported dotnet SDK
2+
============================
3+
4+
The Polyglot Notebok extension requires the dotnet SDK version 7.0 or later, and it can be installed from [here](https://dotnet.microsoft.com/en-us/download). Once installed please restart VS Code.

src/dotnet-interactive-vscode/UPDATING-TO-NEW-VERSION-OF-STABLE.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ Updating to new version of stable
22
=================================
33

44
1. Copy `<root>/src/dotnet-interactive-vscode-insiders/package.json` to `<root>/src/dotnet-interactive-vscode/`
5-
2. Copy `<root>/src/dotnet-interactive-vscode-insiders/src/*` to `<root>/src/dotnet-interactive-vscode/src/` **EXCEPT** for the `vscode-common` symlinked directory.
6-
3. Increment verion number in `vscodeStableVersion.txt` to match the upcoming stable release of VS Code.
7-
4. `.\update-api.ps1`
8-
5. `.\update-versions.ps1 -updateAll`
9-
6. For each directory:
5+
2. Copy `<root>/src/dotnet-interactive-vscode-insiders/help/*` to `<root>/src/dotnet-interactive-vscode/help/`
6+
3. Copy `<root>/src/dotnet-interactive-vscode-insiders/src/*` to `<root>/src/dotnet-interactive-vscode/src/` **EXCEPT** for the `vscode-common` symlinked directory.
7+
4. Increment verion number in `vscodeStableVersion.txt` to match the upcoming stable release of VS Code.
8+
5. `.\update-api.ps1`
9+
6. `.\update-versions.ps1 -updateAll`
10+
7. For each directory:
1011
- `<root>/src/dotnet-interactive-vscode`
1112
- `<root>/src/dotnet-interactive-vscode-insiders`
1213
- `npm i`
1314
- `npm run compile`
1415
- `npm run test`
15-
7. `git add .`, `git commit`
16+
8. `git add .`, `git commit`
1617

1718
Validating
1819
==========
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Install supported dotnet SDK
2+
============================
3+
4+
The Polyglot Notebok extension requires the dotnet SDK version 7.0 or later, and it can be installed from [here](https://dotnet.microsoft.com/en-us/download). Once installed please restart VS Code.

0 commit comments

Comments
 (0)