Skip to content

Commit e230b12

Browse files
Provide actionable steps to the user when an OmniSharp server specific to the current Linux distribution can't be found
1 parent 1b5c407 commit e230b12

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/omnisharpServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export abstract class OmnisharpServer {
264264
this._fireEvent(Events.StdOut, `[INFO] Starting OmniSharp at '${solutionPath}'...\n`);
265265
this._fireEvent(Events.BeforeServerStart, solutionPath);
266266

267-
return omnisharpLauncher(cwd, argv).then(value => {
267+
return omnisharpLauncher(this._channel, cwd, argv).then(value => {
268268
this._serverProcess = value.process;
269269
this._requestDelays = {};
270270
this._fireEvent(Events.StdOut, `[INFO] Started OmniSharp from '${value.command}' with process id ${value.process.pid}...\n`);

src/omnisharpServerLauncher.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77

88
import {exists as fileExists} from 'fs';
99
import {spawn, ChildProcess} from 'child_process';
10-
import {workspace} from 'vscode';
10+
import {workspace, OutputChannel} from 'vscode';
1111
import {satisfies} from 'semver';
1212
import {join} from 'path';
1313
import {getOmnisharpLaunchFilePath} from './omnisharpPath';
1414
import {downloadOmnisharp} from './omnisharpDownload';
15+
import {SupportedPlatform, getSupportedPlatform} from './utils';
1516

1617
const isWindows = process.platform === 'win32';
1718

@@ -20,20 +21,34 @@ export interface LaunchResult {
2021
command: string;
2122
}
2223

23-
export function installOmnisharpIfNeeded(): Promise<string> {
24+
export function installOmnisharpIfNeeded(output: OutputChannel): Promise<string> {
2425
return getOmnisharpLaunchFilePath().catch(err => {
26+
if (getSupportedPlatform() == SupportedPlatform.None && process.platform === 'linux') {
27+
output.appendLine("[ERROR] Could not locate an OmniSharp server that supports your Linux distribution.");
28+
output.appendLine("");
29+
output.appendLine("OmniSharp provides a richer C# editing experience, with features like IntelliSense and Find All References.");
30+
output.appendLine("It is recommend that you download the version of OmniSharp that runs on Mono using the following steps:");
31+
output.appendLine(" 1. If it's not already installed, download and install Mono (http://www.mono-project.com)");
32+
output.appendLine(" 2. Download and untar https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.9-alpha13/omnisharp-linux-mono.tar.gz");
33+
output.appendLine(" 3. In Visual Studio Code, select Preferences->User Settings to open settings.json.");
34+
output.appendLine(" 4. In settings.json, add a new setting: \"csharp.omnisharp\": \"/path/to/omnisharp/OmniSharp.exe\"");
35+
output.appendLine(" 5. Restart Visual Studio Code.");
36+
output.show();
37+
throw err;
38+
}
39+
2540
return downloadOmnisharp().then(_ => {
2641
return getOmnisharpLaunchFilePath();
2742
})
2843
});
2944
}
3045

31-
export default function launch(cwd: string, args: string[]): Promise<LaunchResult> {
46+
export default function launch(output: OutputChannel, cwd: string, args: string[]): Promise<LaunchResult> {
3247

3348
return new Promise<LaunchResult>((resolve, reject) => {
3449

3550
try {
36-
(isWindows ? launchWindows(cwd, args) : launchNix(cwd, args)).then(value => {
51+
(isWindows ? launchWindows(output, cwd, args) : launchNix(output, cwd, args)).then(value => {
3752

3853
// async error - when target not not ENEOT
3954
value.process.on('error', reject);
@@ -52,8 +67,8 @@ export default function launch(cwd: string, args: string[]): Promise<LaunchResul
5267
});
5368
}
5469

55-
function launchWindows(cwd: string, args: string[]): Promise<LaunchResult> {
56-
return installOmnisharpIfNeeded().then(command => {
70+
function launchWindows(output: OutputChannel, cwd: string, args: string[]): Promise<LaunchResult> {
71+
return installOmnisharpIfNeeded(output).then(command => {
5772

5873
args = args.slice(0);
5974
args.unshift(command);
@@ -77,9 +92,9 @@ function launchWindows(cwd: string, args: string[]): Promise<LaunchResult> {
7792
});
7893
}
7994

80-
function launchNix(cwd: string, args: string[]): Promise<LaunchResult>{
95+
function launchNix(output: OutputChannel, cwd: string, args: string[]): Promise<LaunchResult>{
8196

82-
return installOmnisharpIfNeeded().then(command => {
97+
return installOmnisharpIfNeeded(output).then(command => {
8398
let process = spawn(command, args, {
8499
detached: false,
85100
// env: details.env,

0 commit comments

Comments
 (0)