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