Skip to content

Commit 97fc317

Browse files
committed
using version for default omnisharp
1 parent 94d07b6 commit 97fc317

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"keywords": [
2525
"multi-root ready"
2626
],
27+
"defaults":{
28+
"omniSharp" : "1.29.1"
29+
},
2730
"main": "./out/src/main",
2831
"scripts": {
2932
"vscode:prepublish": "tsc -p ./",
@@ -143,7 +146,7 @@
143146
"description": "OmniSharp for Windows (.NET 4.6 / x86)",
144147
"url": "https://download.visualstudio.microsoft.com/download/pr/11655913/afaf4c0f0bee0304c8b1c55dfc190a9f/omnisharp-win-x86-1.29.1.zip",
145148
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x86-1.29.1.zip",
146-
"installPath": ".omnisharp",
149+
"installPath": ".omnisharp/1.29.1",
147150
"platforms": [
148151
"win32"
149152
],
@@ -157,7 +160,7 @@
157160
"description": "OmniSharp for Windows (.NET 4.6 / x64)",
158161
"url": "https://download.visualstudio.microsoft.com/download/pr/11655914/fc5dedbd95030e4015ffc24e48177255/omnisharp-win-x64-1.29.1.zip",
159162
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x64-1.29.1.zip",
160-
"installPath": ".omnisharp",
163+
"installPath": ".omnisharp/1.29.1",
161164
"platforms": [
162165
"win32"
163166
],
@@ -171,7 +174,7 @@
171174
"description": "OmniSharp for OSX",
172175
"url": "https://download.visualstudio.microsoft.com/download/pr/11655911/eee9835195b397df4c80ca16c51e1a58/omnisharp-osx-1.29.1.zip",
173176
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-osx-1.29.1.zip",
174-
"installPath": ".omnisharp",
177+
"installPath": ".omnisharp/1.29.1",
175178
"platforms": [
176179
"darwin"
177180
],
@@ -186,7 +189,7 @@
186189
"description": "OmniSharp for Linux (x86)",
187190
"url": "https://download.visualstudio.microsoft.com/download/pr/11655910/48d2fd69a5061fee074219c8a9b37232/omnisharp-linux-x86-1.29.1.zip",
188191
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-linux-x86-1.29.1.zip",
189-
"installPath": ".omnisharp",
192+
"installPath": ".omnisharp/1.29.1",
190193
"platforms": [
191194
"linux"
192195
],
@@ -205,7 +208,7 @@
205208
"description": "OmniSharp for Linux (x64)",
206209
"url": "https://download.visualstudio.microsoft.com/download/pr/11655912/d0b11407c8b6a61cc0cf8071b2a07c87/omnisharp-linux-x64-1.29.1.zip",
207210
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-linux-x64-1.29.1.zip",
208-
"installPath": ".omnisharp",
211+
"installPath": ".omnisharp/1.29.1",
209212
"platforms": [
210213
"linux"
211214
],

src/omnisharp/OmnisharpManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export class OmnisharpManager {
2020
private platformInfo: PlatformInformation) {
2121
}
2222

23-
public async GetOmniSharpLaunchInfo(omnisharpPath: string, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
23+
public async GetOmniSharpLaunchInfo(defaultOmnisharpVersion: string, omnisharpPath: string, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
2424
if (!omnisharpPath) {
2525
// If omnisharpPath was not specified, return the default path.
26-
let basePath = path.resolve(extensionPath, '.omnisharp');
26+
let basePath = path.resolve(extensionPath, '.omnisharp', defaultOmnisharpVersion);
2727
return this.GetLaunchInfo(this.platformInfo, basePath);
2828
}
2929

src/omnisharp/server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module Events {
6868

6969
const TelemetryReportingDelay = 2 * 60 * 1000; // two minutes
7070
const serverUrl = "https://roslynomnisharp.blob.core.windows.net";
71-
const installPath = ".omnisharp/experimental";
71+
const installPath = ".omnisharp";
7272
const latestVersionFileServerPath = 'releases/versioninfo.txt';
7373

7474
export class OmniSharpServer {
@@ -91,9 +91,9 @@ export class OmniSharpServer {
9191
private updateProjectDebouncer = new Subject<ObservableEvents.ProjectModified>();
9292
private firstUpdateProject: boolean;
9393

94-
constructor(private vscode: vscode, networkSettingsProvider: NetworkSettingsProvider, private eventStream: EventStream, packageJSON: any, private platformInfo: PlatformInformation) {
94+
constructor(private vscode: vscode, networkSettingsProvider: NetworkSettingsProvider, private eventStream: EventStream, private packageJSON: any, private platformInfo: PlatformInformation) {
9595
this._requestQueue = new RequestQueueCollection(this.eventStream, 8, request => this._makeRequest(request));
96-
let downloader = new OmnisharpDownloader(networkSettingsProvider, this.eventStream, packageJSON, platformInfo);
96+
let downloader = new OmnisharpDownloader(networkSettingsProvider, this.eventStream, this.packageJSON, platformInfo);
9797
this._omnisharpManager = new OmnisharpManager(downloader, platformInfo);
9898
this.updateProjectDebouncer.debounceTime(1500).subscribe((event) => { this.updateProjectInfo(); });
9999
this.firstUpdateProject = true;
@@ -310,7 +310,7 @@ export class OmniSharpServer {
310310
let launchInfo: LaunchInfo;
311311
try {
312312
let extensionPath = utils.getExtensionPath();
313-
launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this._options.path, serverUrl, latestVersionFileServerPath, installPath, extensionPath);
313+
launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this.packageJSON.defaults.omniSharp,this._options.path, serverUrl, latestVersionFileServerPath, installPath, extensionPath);
314314
}
315315
catch (error) {
316316
this.eventStream.post(new ObservableEvents.OmnisharpFailure(`Error occured in loading omnisharp from omnisharp.path\nCould not start the server due to ${error.toString()}`, error));

test/featureTests/OmnisharpManager.test.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ const tmp = require('tmp');
2020
suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path depending on the path and useMono option', () => {
2121
const platformInfo = new PlatformInformation("win32", "x86");
2222
const serverUrl = "https://roslynomnisharp.blob.core.windows.net";
23-
const installPath = ".omnisharp/experimental";
23+
const installPath = "somePath";
2424
const versionFilepathInServer = "releases/testVersionInfo.txt";
2525
const eventStream = new EventStream();
2626
const manager = GetTestOmnisharpManager(eventStream, platformInfo);
27+
const defaultVersion = "0.1.2";
2728
let extensionPath: string;
2829
let tmpDir: any;
2930
let tmpFile: any;
@@ -37,68 +38,68 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin
3738
});
3839

3940
test('Throws error if the path is neither an absolute path nor a valid semver, nor the string "latest"', async () => {
40-
expect(manager.GetOmniSharpLaunchInfo("Some incorrect path", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
41+
expect(manager.GetOmniSharpLaunchInfo(defaultVersion, "Some incorrect path", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
4142
});
4243

4344
test('Throws error when the specified path is null', async () => {
44-
expect(manager.GetOmniSharpLaunchInfo(null, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
45+
expect(manager.GetOmniSharpLaunchInfo(defaultVersion, null, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
4546
});
4647

4748
test('Throws error when the specified path is empty', async () => {
48-
expect(manager.GetOmniSharpLaunchInfo("", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
49+
expect(manager.GetOmniSharpLaunchInfo(defaultVersion, "", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
4950
});
5051

5152
test('Throws error when the specified path is an invalid semver', async () => {
52-
expect(manager.GetOmniSharpLaunchInfo("a.b.c", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
53+
expect(manager.GetOmniSharpLaunchInfo(defaultVersion, "a.b.c", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
5354
});
5455

5556
test('Returns default paths if no path is specified', async () => {
56-
let launchInfo = await manager.GetOmniSharpLaunchInfo(undefined, serverUrl, versionFilepathInServer, installPath, extensionPath);
57-
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/OmniSharp.exe'));
57+
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, undefined, serverUrl, versionFilepathInServer, installPath, extensionPath);
58+
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/${defaultVersion}/OmniSharp.exe`));
5859
expect(launchInfo.MonoLaunchPath).to.be.undefined;
5960
});
6061

6162
test('Returns default paths if no path is specified - Linux ', async () => {
6263
let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64"));
63-
let launchInfo = await manager.GetOmniSharpLaunchInfo(undefined, serverUrl, versionFilepathInServer, installPath, extensionPath);
64-
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/run'));
65-
launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/omnisharp/OmniSharp.exe'));
64+
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, undefined, serverUrl, versionFilepathInServer, installPath, extensionPath);
65+
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/${defaultVersion}/run`));
66+
launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/${defaultVersion}/omnisharp/OmniSharp.exe`));
6667
});
6768

6869
test('Returns the same path if absolute path to an existing file is passed', async () => {
6970
tmpFile = tmp.fileSync();
70-
let launchInfo = await manager.GetOmniSharpLaunchInfo(tmpFile.name, serverUrl, versionFilepathInServer, installPath, extensionPath);
71+
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, tmpFile.name, serverUrl, versionFilepathInServer, installPath, extensionPath);
7172
launchInfo.LaunchPath.should.equal(tmpFile.name);
7273
});
7374

7475
test('Installs the latest version and returns the launch path based on the version and platform', async () => {
75-
let launchInfo = await manager.GetOmniSharpLaunchInfo("latest", serverUrl, versionFilepathInServer, installPath, extensionPath);
76-
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`));
76+
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "latest", serverUrl, versionFilepathInServer, installPath, extensionPath);
77+
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `somePath/1.2.3/OmniSharp.exe`));
7778
expect(launchInfo.MonoLaunchPath).to.be.undefined;
7879
});
7980

8081
test('Installs the test version and returns the launch path based on the version and platform', async () => {
81-
let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
82-
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`));
82+
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
83+
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `somePath/1.2.3/OmniSharp.exe`));
8384
expect(launchInfo.MonoLaunchPath).to.be.undefined;
8485
});
8586

8687
test('Downloads package from given url and installs them at the specified path', async () => {
87-
await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
88-
let exists = await util.fileExists(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/install_check_1.2.3.txt`));
88+
await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
89+
let exists = await util.fileExists(path.resolve(extensionPath, `somePath/1.2.3/install_check_1.2.3.txt`));
8990
exists.should.equal(true);
9091
});
9192

9293
test('Downloads package and returns launch path based on platform - on Linux ', async () => {
9394
let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64"));
94-
let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
95-
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/run'));
96-
launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/omnisharp/OmniSharp.exe'));
95+
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
96+
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, 'somePath/1.2.3/run'));
97+
launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, 'somePath/1.2.3/omnisharp/OmniSharp.exe'));
9798
});
9899

99100
test('Downloads package and returns launch path based on install path ', async () => {
100101
let manager = GetTestOmnisharpManager(eventStream, platformInfo);
101-
let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, "installHere", extensionPath);
102+
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, "installHere", extensionPath);
102103
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, 'installHere/1.2.3/OmniSharp.exe'));
103104
expect(launchInfo.MonoLaunchPath).to.be.undefined;
104105
});

0 commit comments

Comments
 (0)