Skip to content

Commit 1f36112

Browse files
committed
Support using .NET 6 OmniSharp
Adds an option for using the .NET 6 version of OmniSharp, and supports getting it and the right executables on all platforms.
1 parent 8d8e9cc commit 1f36112

File tree

13 files changed

+627
-275
lines changed

13 files changed

+627
-275
lines changed

package.json

Lines changed: 135 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,27 @@
138138
],
139139
"installTestPath": "./.omnisharp/1.37.17/OmniSharp.exe",
140140
"platformId": "win-x86",
141+
"isFramework": true,
141142
"integrity": "95ECBABF821ED45E4E6F3173E2165C5F593FC4611040475DBD6D54C16D78F4F8"
142143
},
144+
{
145+
"id": "OmniSharp",
146+
"description": "OmniSharp for Windows (.NET 6 / x86)",
147+
"url": null,
148+
"fallbackUrl": null,
149+
"installPath": null,
150+
"platforms": [
151+
"win32"
152+
],
153+
"architectures": [
154+
"x86",
155+
"arm64"
156+
],
157+
"installTestPath": null,
158+
"platformId": "win-x86",
159+
"isFramework": false,
160+
"integrity": null
161+
},
143162
{
144163
"id": "OmniSharp",
145164
"description": "OmniSharp for Windows (.NET 4.6 / x64)",
@@ -154,11 +173,29 @@
154173
],
155174
"installTestPath": "./.omnisharp/1.37.17/OmniSharp.exe",
156175
"platformId": "win-x64",
176+
"isFramework": true,
157177
"integrity": "BD81F1284FA4A9E6D63292074D0304B65CD39C24539CB761B54E8727619070DF"
158178
},
159179
{
160180
"id": "OmniSharp",
161-
"description": "OmniSharp for OSX",
181+
"description": "OmniSharp for Windows (.NET 6 / x64)",
182+
"url": null,
183+
"fallbackUrl": null,
184+
"installPath": null,
185+
"platforms": [
186+
"win32"
187+
],
188+
"architectures": [
189+
"x86_64"
190+
],
191+
"installTestPath": null,
192+
"platformId": "win-x64",
193+
"isFramework": false,
194+
"integrity": null
195+
},
196+
{
197+
"id": "OmniSharp",
198+
"description": "OmniSharp for OSX (Mono)",
162199
"url": "https://download.visualstudio.microsoft.com/download/pr/47df6cf8-7648-4fff-9e9c-304f0202d31c/9f560aead2b823079775c00110972c04/omnisharp-osx-1.37.17.zip",
163200
"fallbackUrl": "https://roslynomnisharp.blob.core.windows.net/releases/1.37.17/omnisharp-osx-1.37.17.zip",
164201
"installPath": ".omnisharp/1.37.17",
@@ -171,11 +208,30 @@
171208
],
172209
"installTestPath": "./.omnisharp/1.37.17/run",
173210
"platformId": "osx",
211+
"isFramework": true,
174212
"integrity": "43D6B18F390B8ED92231044E87413831E565E9AB5938223B19CA97B3628DDDF4"
175213
},
176214
{
177215
"id": "OmniSharp",
178-
"description": "OmniSharp for Linux (x86)",
216+
"description": "OmniSharp for OSX (.NET 6)",
217+
"url": null,
218+
"fallbackUrl": null,
219+
"installPath": null,
220+
"platforms": [
221+
"darwin"
222+
],
223+
"binaries": [
224+
"./mono.osx",
225+
"./run"
226+
],
227+
"installTestPath": null,
228+
"platformId": "osx",
229+
"isFramework": false,
230+
"integrity": null
231+
},
232+
{
233+
"id": "OmniSharp",
234+
"description": "OmniSharp for Linux (Mono, x86)",
179235
"url": "https://download.visualstudio.microsoft.com/download/pr/47df6cf8-7648-4fff-9e9c-304f0202d31c/6f3d66d4ffa4fa627225221fb00e106e/omnisharp-linux-x86-1.37.17.zip",
180236
"fallbackUrl": "https://roslynomnisharp.blob.core.windows.net/releases/1.37.17/omnisharp-linux-x86-1.37.17.zip",
181237
"installPath": ".omnisharp/1.37.17",
@@ -192,11 +248,34 @@
192248
],
193249
"installTestPath": "./.omnisharp/1.37.17/run",
194250
"platformId": "linux-x86",
251+
"isFramework": true,
195252
"integrity": "75676E50D9FB62B9DC20A6A10E65420B54EFE2FFAE80AC21F59A4C483A4902BB"
196253
},
197254
{
198255
"id": "OmniSharp",
199-
"description": "OmniSharp for Linux (x64)",
256+
"description": "OmniSharp for Linux (.NET 6 x86)",
257+
"url": null,
258+
"fallbackUrl": null,
259+
"installPath": null,
260+
"platforms": [
261+
"linux"
262+
],
263+
"architectures": [
264+
"x86",
265+
"i686"
266+
],
267+
"binaries": [
268+
"./mono.linux-x86",
269+
"./run"
270+
],
271+
"installTestPath": null,
272+
"platformId": "linux-x86",
273+
"isFramework": false,
274+
"integrity": null
275+
},
276+
{
277+
"id": "OmniSharp",
278+
"description": "OmniSharp for Linux (Mono, x64)",
200279
"url": "https://download.visualstudio.microsoft.com/download/pr/47df6cf8-7648-4fff-9e9c-304f0202d31c/6cf1b92d91f942929922013b2139cca9/omnisharp-linux-x64-1.37.17.zip",
201280
"fallbackUrl": "https://roslynomnisharp.blob.core.windows.net/releases/1.37.17/omnisharp-linux-x64-1.37.17.zip",
202281
"installPath": ".omnisharp/1.37.17",
@@ -212,11 +291,33 @@
212291
],
213292
"installTestPath": "./.omnisharp/1.37.17/run",
214293
"platformId": "linux-x64",
294+
"isFramework": true,
215295
"integrity": "34276181B4C1F9968AFA10DEC058F6A2D79DE362FA01B565A04E879CA84A74FE"
216296
},
217297
{
218298
"id": "OmniSharp",
219-
"description": "OmniSharp for Linux (arm64)",
299+
"description": "OmniSharp for Linux (.NET 6, x64)",
300+
"url": null,
301+
"fallbackUrl": null,
302+
"installPath": null,
303+
"platforms": [
304+
"linux"
305+
],
306+
"architectures": [
307+
"x86_64"
308+
],
309+
"binaries": [
310+
"./mono.linux-x86_64",
311+
"./run"
312+
],
313+
"installTestPath": null,
314+
"platformId": "linux-x64",
315+
"isFramework": false,
316+
"integrity": null
317+
},
318+
{
319+
"id": "OmniSharp",
320+
"description": "OmniSharp for Linux (Framework, arm64)",
220321
"url": null,
221322
"fallbackUrl": null,
222323
"installPath": null,
@@ -232,7 +333,29 @@
232333
],
233334
"installTestPath": null,
234335
"platformId": "linux-arm64",
235-
"integrity": null
336+
"integrity": null,
337+
"isFramework": true
338+
},
339+
{
340+
"id": "OmniSharp",
341+
"description": "OmniSharp for Linux (.NET 6, arm64)",
342+
"url": null,
343+
"fallbackUrl": null,
344+
"installPath": null,
345+
"platforms": [
346+
"linux"
347+
],
348+
"architectures": [
349+
"arm64"
350+
],
351+
"binaries": [
352+
"./mono.linux-arm64",
353+
"./run"
354+
],
355+
"installTestPath": null,
356+
"platformId": "linux-arm64",
357+
"integrity": null,
358+
"isFramework": false
236359
},
237360
{
238361
"id": "Debugger",
@@ -742,6 +865,13 @@
742865
"scope": "machine",
743866
"description": "Specifies the path to OmniSharp. When left empty the OmniSharp version pinned to the C# Extension is used. This can be the absolute path to an OmniSharp executable, a specific version number, or \"latest\". If a version number or \"latest\" is specified, the appropriate version of OmniSharp will be downloaded on your behalf. Setting \"latest\" is an opt-in into latest beta releases of OmniSharp."
744867
},
868+
"omnisharp.useModernNet": {
869+
"type": "boolean",
870+
"default": "false",
871+
"scope": "window",
872+
"title": "Use .NET 6 build of OmniSharp (experimental)",
873+
"description": "Use OmniSharp build for .NET 6. This version _does not_ support non-SDK-style .NET Framework projects, including Unity. SDK-style Framework, .NET Core, and .NET 5+ projects should see significant performance improvements, but there may still be bugs. Please open issues if you find any bugs."
874+
},
745875
"omnisharp.useGlobalMono": {
746876
"type": "string",
747877
"default": "auto",

src/observers/OptionChangeObserver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const omniSharpOptions: ReadonlyArray<OptionsKey> = [
2323
"enableImportCompletion",
2424
"organizeImportsOnFormat",
2525
"enableAsyncCompletion",
26+
"useModernNet",
2627
];
2728

2829
function OmniSharpOptionChangeObservable(optionObservable: Observable<Options>): Observable<Options> {

src/omnisharp/OmnisharpDownloader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export class OmnisharpDownloader {
2424
private extensionPath: string) {
2525
}
2626

27-
public async DownloadAndInstallOmnisharp(version: string, serverUrl: string, installPath: string): Promise<boolean> {
27+
public async DownloadAndInstallOmnisharp(version: string, useFramework: boolean, serverUrl: string, installPath: string): Promise<boolean> {
2828
let runtimeDependencies = getRuntimeDependenciesPackages(this.packageJSON);
29-
let omniSharpPackages = GetPackagesFromVersion(version, runtimeDependencies, serverUrl, installPath);
29+
let omniSharpPackages = GetPackagesFromVersion(version, useFramework, runtimeDependencies, serverUrl, installPath);
3030
let packagesToInstall = await getAbsolutePathPackagesToInstall(omniSharpPackages, this.platformInfo, this.extensionPath);
3131
if (packagesToInstall && packagesToInstall.length > 0) {
3232
this.eventStream.post(new PackageInstallation(`OmniSharp Version = ${version}`));
@@ -53,4 +53,4 @@ export class OmnisharpDownloader {
5353
throw error;
5454
}
5555
}
56-
}
56+
}

src/omnisharp/OmnisharpManager.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as semver from 'semver';
88
import * as util from '../common';
99
import { OmnisharpDownloader } from './OmnisharpDownloader';
1010
import { PlatformInformation } from '../platform';
11+
import { modernNetVersion } from './OmnisharpPackageCreator';
1112

1213
export interface LaunchInfo {
1314
LaunchPath: string;
@@ -20,11 +21,11 @@ export class OmnisharpManager {
2021
private platformInfo: PlatformInformation) {
2122
}
2223

23-
public async GetOmniSharpLaunchInfo(defaultOmnisharpVersion: string, omnisharpPath: string, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
24+
public async GetOmniSharpLaunchInfo(defaultOmnisharpVersion: string, omnisharpPath: string, useFramework: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
2425
if (!omnisharpPath) {
2526
// If omnisharpPath was not specified, return the default path.
26-
let basePath = path.resolve(extensionPath, '.omnisharp', defaultOmnisharpVersion);
27-
return this.GetLaunchInfo(this.platformInfo, basePath);
27+
let basePath = path.resolve(extensionPath, '.omnisharp', defaultOmnisharpVersion + (useFramework ? '' : `-net${modernNetVersion}`));
28+
return this.GetLaunchInfo(this.platformInfo, useFramework, basePath);
2829
}
2930

3031
// Looks at the options path, installs the dependencies and returns the path to be loaded by the omnisharp server
@@ -38,48 +39,53 @@ export class OmnisharpManager {
3839
};
3940
}
4041
else if (omnisharpPath === 'latest') {
41-
return await this.InstallLatestAndReturnLaunchInfo(serverUrl, latestVersionFileServerPath, installPath, extensionPath);
42+
return await this.InstallLatestAndReturnLaunchInfo(useFramework, serverUrl, latestVersionFileServerPath, installPath, extensionPath);
4243
}
4344

4445
// If the path is neither a valid path on disk not the string "latest", treat it as a version
45-
return await this.InstallVersionAndReturnLaunchInfo(omnisharpPath, serverUrl, installPath, extensionPath);
46+
return await this.InstallVersionAndReturnLaunchInfo(omnisharpPath, useFramework, serverUrl, installPath, extensionPath);
4647
}
4748

48-
private async InstallLatestAndReturnLaunchInfo(serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
49+
private async InstallLatestAndReturnLaunchInfo(useFramework: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
4950
let version = await this.downloader.GetLatestVersion(serverUrl, latestVersionFileServerPath);
50-
return await this.InstallVersionAndReturnLaunchInfo(version, serverUrl, installPath, extensionPath);
51+
return await this.InstallVersionAndReturnLaunchInfo(version, useFramework, serverUrl, installPath, extensionPath);
5152
}
5253

53-
private async InstallVersionAndReturnLaunchInfo(version: string, serverUrl: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
54+
private async InstallVersionAndReturnLaunchInfo(version: string, useFramework: boolean, serverUrl: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
5455
if (semver.valid(version)) {
55-
await this.downloader.DownloadAndInstallOmnisharp(version, serverUrl, installPath);
56-
return this.GetLaunchPathForVersion(this.platformInfo, version, installPath, extensionPath);
56+
await this.downloader.DownloadAndInstallOmnisharp(version, useFramework, serverUrl, installPath);
57+
return this.GetLaunchPathForVersion(this.platformInfo, useFramework, version, installPath, extensionPath);
5758
}
5859
else {
5960
throw new Error(`Invalid OmniSharp version - ${version}`);
6061
}
6162
}
6263

63-
private GetLaunchPathForVersion(platformInfo: PlatformInformation, version: string, installPath: string, extensionPath: string): LaunchInfo {
64+
private GetLaunchPathForVersion(platformInfo: PlatformInformation, isFramework: boolean, version: string, installPath: string, extensionPath: string): LaunchInfo {
6465
if (!version) {
6566
throw new Error('Invalid Version');
6667
}
6768

68-
let basePath = path.resolve(extensionPath, installPath, version);
69+
let basePath = path.resolve(extensionPath, installPath, version + (isFramework ? '' : `-net${modernNetVersion}`));
6970

70-
return this.GetLaunchInfo(platformInfo, basePath);
71+
return this.GetLaunchInfo(platformInfo, isFramework, basePath);
7172
}
7273

73-
private GetLaunchInfo(platformInfo: PlatformInformation, basePath: string): LaunchInfo {
74+
private GetLaunchInfo(platformInfo: PlatformInformation, isFramework: boolean, basePath: string): LaunchInfo {
7475
if (platformInfo.isWindows()) {
7576
return {
7677
LaunchPath: path.join(basePath, 'OmniSharp.exe')
7778
};
7879
}
80+
else if (!isFramework) {
81+
return {
82+
LaunchPath: path.join(basePath, 'OmniSharp')
83+
};
84+
}
7985

8086
return {
8187
LaunchPath: path.join(basePath, 'run'),
8288
MonoLaunchPath: path.join(basePath, 'omnisharp', 'OmniSharp.exe')
8389
};
8490
}
85-
}
91+
}

src/omnisharp/OmnisharpPackageCreator.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,56 @@
55

66
import { Package } from "../packageManager/Package";
77

8-
export function GetPackagesFromVersion(version: string, runTimeDependencies: Package[], serverUrl: string, installPath: string): Package[] {
8+
export const modernNetVersion = "6.0";
9+
10+
export function GetPackagesFromVersion(version: string, useFramework: boolean, runTimeDependencies: Package[], serverUrl: string, installPath: string): Package[] {
911
if (!version) {
1012
throw new Error('Invalid version');
1113
}
1214

1315
let versionPackages = new Array<Package>();
1416
for (let inputPackage of runTimeDependencies) {
15-
if (inputPackage.platformId) {
16-
versionPackages.push(SetBinaryAndGetPackage(inputPackage, serverUrl, version, installPath));
17+
if (inputPackage.platformId && inputPackage.isFramework === useFramework) {
18+
versionPackages.push(SetBinaryAndGetPackage(inputPackage, useFramework, serverUrl, version, installPath));
1719
}
1820
}
1921

2022
return versionPackages;
2123
}
2224

23-
export function SetBinaryAndGetPackage(inputPackage: Package, serverUrl: string, version: string, installPath: string): Package {
25+
export function SetBinaryAndGetPackage(inputPackage: Package, useFramework: boolean, serverUrl: string, version: string, installPath: string): Package {
2426
let installBinary: string;
2527
if (inputPackage.platformId === "win-x86" || inputPackage.platformId === "win-x64") {
2628
installBinary = "OmniSharp.exe";
2729
}
30+
else if (!useFramework) {
31+
installBinary = 'OmniSharp';
32+
}
2833
else {
2934
installBinary = "run";
3035
}
3136

32-
return GetPackage(inputPackage, serverUrl, version, installPath, installBinary);
37+
return GetPackage(inputPackage, useFramework, serverUrl, version, installPath, installBinary);
3338
}
3439

35-
function GetPackage(inputPackage: Package, serverUrl: string, version: string, installPath: string, installBinary: string): Package {
40+
function GetPackage(inputPackage: Package, useFramework: boolean, serverUrl: string, version: string, installPath: string, installBinary: string): Package {
3641
if (!version) {
3742
throw new Error('Invalid version');
3843
}
3944

45+
const packageSuffix = useFramework ? '' : `-net${modernNetVersion}`;
46+
4047
let versionPackage: Package = {
4148
id: inputPackage.id,
4249
description: `${inputPackage.description}, Version = ${version}`,
43-
url: `${serverUrl}/releases/${version}/omnisharp-${inputPackage.platformId}.zip`,
44-
installPath: `${installPath}/${version}`,
45-
installTestPath: `./${installPath}/${version}/${installBinary}`,
50+
url: `${serverUrl}/releases/${version}/omnisharp-${inputPackage.platformId}${packageSuffix}.zip`,
51+
installPath: `${installPath}/${version}${packageSuffix}`,
52+
installTestPath: `./${installPath}/${version}${packageSuffix}/${installBinary}`,
4653
platforms: inputPackage.platforms,
4754
architectures: inputPackage.architectures,
4855
binaries: inputPackage.binaries,
49-
platformId: inputPackage.platformId
56+
platformId: inputPackage.platformId,
57+
isFramework: useFramework
5058
};
5159

5260
return versionPackage;

0 commit comments

Comments
 (0)