7
7
8
8
import { exists as fileExists } from 'fs' ;
9
9
import { spawn , ChildProcess } from 'child_process' ;
10
- import { workspace } from 'vscode' ;
10
+ import { workspace , OutputChannel } from 'vscode' ;
11
11
import { satisfies } from 'semver' ;
12
12
import { join } from 'path' ;
13
13
import { getOmnisharpLaunchFilePath } from './omnisharpPath' ;
14
14
import { downloadOmnisharp } from './omnisharpDownload' ;
15
+ import { SupportedPlatform , getSupportedPlatform } from './utils' ;
15
16
16
17
const isWindows = process . platform === 'win32' ;
17
18
@@ -20,20 +21,34 @@ export interface LaunchResult {
20
21
command : string ;
21
22
}
22
23
23
- export function installOmnisharpIfNeeded ( ) : Promise < string > {
24
+ export function installOmnisharpIfNeeded ( output : OutputChannel ) : Promise < string > {
24
25
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
+
25
40
return downloadOmnisharp ( ) . then ( _ => {
26
41
return getOmnisharpLaunchFilePath ( ) ;
27
42
} )
28
43
} ) ;
29
44
}
30
45
31
- export default function launch ( cwd : string , args : string [ ] ) : Promise < LaunchResult > {
46
+ export default function launch ( output : OutputChannel , cwd : string , args : string [ ] ) : Promise < LaunchResult > {
32
47
33
48
return new Promise < LaunchResult > ( ( resolve , reject ) => {
34
49
35
50
try {
36
- ( isWindows ? launchWindows ( cwd , args ) : launchNix ( cwd , args ) ) . then ( value => {
51
+ ( isWindows ? launchWindows ( output , cwd , args ) : launchNix ( output , cwd , args ) ) . then ( value => {
37
52
38
53
// async error - when target not not ENEOT
39
54
value . process . on ( 'error' , reject ) ;
@@ -52,8 +67,8 @@ export default function launch(cwd: string, args: string[]): Promise<LaunchResul
52
67
} ) ;
53
68
}
54
69
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 => {
57
72
58
73
args = args . slice ( 0 ) ;
59
74
args . unshift ( command ) ;
@@ -77,9 +92,9 @@ function launchWindows(cwd: string, args: string[]): Promise<LaunchResult> {
77
92
} ) ;
78
93
}
79
94
80
- function launchNix ( cwd : string , args : string [ ] ) : Promise < LaunchResult > {
95
+ function launchNix ( output : OutputChannel , cwd : string , args : string [ ] ) : Promise < LaunchResult > {
81
96
82
- return installOmnisharpIfNeeded ( ) . then ( command => {
97
+ return installOmnisharpIfNeeded ( output ) . then ( command => {
83
98
let process = spawn ( command , args , {
84
99
detached : false ,
85
100
// env: details.env,
0 commit comments