Skip to content

Commit 1b5c407

Browse files
Update with latest OmniSharp and pick correct version for current Linux distribution
We've updated OmniSharp to build releases for each Linux distribution that we currently support: CentOS, Debian, Red Hat (RHEL), and Ubuntu. This change adds code to sniff out which of the supported Linux distros we're running on to determine which flavor of OmniSharp we need to download and install.
1 parent d646e1c commit 1b5c407

File tree

3 files changed

+67
-8
lines changed

3 files changed

+67
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "csharp",
33
"publisher": "ms-vscode",
4-
"version": "1.0.1-rc2",
4+
"version": "1.0.2-rc2",
55
"description": "C# for Visual Studio Code (powered by OmniSharp).",
66
"displayName": "C#",
77
"author": "Microsoft Corporation",

src/omnisharpDownload.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,39 @@
88
import * as fs from 'fs-extra-promise';
99
import * as path from 'path';
1010
import * as tmp from 'tmp';
11+
import {SupportedPlatform, getSupportedPlatform} from './utils';
1112

1213
const Decompress = require('decompress');
1314
const Github = require('github-releases');
1415

1516
const OmnisharpRepo = 'OmniSharp/omnisharp-roslyn';
16-
const OmnisharpVersion = 'v1.9-alpha10';
17+
const OmnisharpVersion = 'v1.9-alpha13';
1718
const DefaultInstallLocation = path.join(__dirname, '../.omnisharp');
1819

1920
tmp.setGracefulCleanup();
2021

2122
function getOmnisharpAssetName(): string {
22-
switch (process.platform) {
23-
case 'win32':
23+
switch (getSupportedPlatform()) {
24+
case SupportedPlatform.Windows:
2425
return 'omnisharp-win-x64-net451.zip';
25-
case 'darwin':
26+
case SupportedPlatform.OSX:
2627
return 'omnisharp-osx-x64-netcoreapp1.0.tar.gz';
27-
case 'linux':
28-
return 'omnisharp-linux-x64-netcoreapp1.0.tar.gz';
28+
case SupportedPlatform.CentOS:
29+
return 'omnisharp-centos-x64-netcoreapp1.0.tar.gz';
30+
case SupportedPlatform.Debian:
31+
return 'omnisharp-debian-x64-netcoreapp1.0.tar.gz';
32+
case SupportedPlatform.RHEL:
33+
return 'omnisharp-rhel-x64-netcoreapp1.0.tar.gz';
34+
case SupportedPlatform.Ubuntu:
35+
return 'omnisharp-ubuntu-x64-netcoreapp1.0.tar.gz';
36+
2937
default:
30-
throw new Error(`Unsupported platform: ${process.platform}`);
38+
if (process.platform === 'linux') {
39+
throw new Error(`Unsupported linux distribution`);
40+
}
41+
else {
42+
throw new Error(`Unsupported platform: ${process.platform}`);
43+
}
3144
}
3245
}
3346

src/utils.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
'use strict';
7+
8+
import * as child_process from 'child_process'
9+
10+
export enum SupportedPlatform {
11+
None,
12+
Windows,
13+
OSX,
14+
CentOS,
15+
Debian,
16+
RHEL,
17+
Ubuntu
18+
}
19+
20+
export function getSupportedPlatform() {
21+
if (process.platform === 'win32') {
22+
return SupportedPlatform.Windows;
23+
}
24+
else if (process.platform === 'darwin') {
25+
return SupportedPlatform.OSX;
26+
}
27+
else if (process.platform === 'linux') {
28+
// Get the text of /etc/*-release to discover which Linux distribution we're running on.
29+
let release = child_process.execSync('cat /etc/*-release').toString().toLowerCase();
30+
31+
if (release.indexOf('ubuntu') >= 0) {
32+
return SupportedPlatform.Ubuntu;
33+
}
34+
else if (release.indexOf('centos') >= 0) {
35+
return SupportedPlatform.CentOS;
36+
}
37+
else if (release.indexOf('rhel') >= 0) {
38+
return SupportedPlatform.RHEL;
39+
}
40+
else if (release.indexOf('debian') >= 0) {
41+
return SupportedPlatform.Debian;
42+
}
43+
}
44+
45+
return SupportedPlatform.None;
46+
}

0 commit comments

Comments
 (0)