diff --git a/package.json b/package.json index 46c4450b90..f15dd2230e 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,9 @@ "keywords": [ "multi-root ready" ], + "defaults":{ + "omniSharp" : "1.29.1" + }, "main": "./out/src/main", "scripts": { "vscode:prepublish": "tsc -p ./", @@ -143,7 +146,7 @@ "description": "OmniSharp for Windows (.NET 4.6 / x86)", "url": "https://download.visualstudio.microsoft.com/download/pr/11655913/afaf4c0f0bee0304c8b1c55dfc190a9f/omnisharp-win-x86-1.29.1.zip", "fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x86-1.29.1.zip", - "installPath": ".omnisharp", + "installPath": ".omnisharp/1.29.1", "platforms": [ "win32" ], @@ -157,7 +160,7 @@ "description": "OmniSharp for Windows (.NET 4.6 / x64)", "url": "https://download.visualstudio.microsoft.com/download/pr/11655914/fc5dedbd95030e4015ffc24e48177255/omnisharp-win-x64-1.29.1.zip", "fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x64-1.29.1.zip", - "installPath": ".omnisharp", + "installPath": ".omnisharp/1.29.1", "platforms": [ "win32" ], @@ -171,7 +174,7 @@ "description": "OmniSharp for OSX", "url": "https://download.visualstudio.microsoft.com/download/pr/11655911/eee9835195b397df4c80ca16c51e1a58/omnisharp-osx-1.29.1.zip", "fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-osx-1.29.1.zip", - "installPath": ".omnisharp", + "installPath": ".omnisharp/1.29.1", "platforms": [ "darwin" ], @@ -186,7 +189,7 @@ "description": "OmniSharp for Linux (x86)", "url": "https://download.visualstudio.microsoft.com/download/pr/11655910/48d2fd69a5061fee074219c8a9b37232/omnisharp-linux-x86-1.29.1.zip", "fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-linux-x86-1.29.1.zip", - "installPath": ".omnisharp", + "installPath": ".omnisharp/1.29.1", "platforms": [ "linux" ], @@ -205,7 +208,7 @@ "description": "OmniSharp for Linux (x64)", "url": "https://download.visualstudio.microsoft.com/download/pr/11655912/d0b11407c8b6a61cc0cf8071b2a07c87/omnisharp-linux-x64-1.29.1.zip", "fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-linux-x64-1.29.1.zip", - "installPath": ".omnisharp", + "installPath": ".omnisharp/1.29.1", "platforms": [ "linux" ], diff --git a/src/omnisharp/OmnisharpManager.ts b/src/omnisharp/OmnisharpManager.ts index 5dbfedb153..38513c0f39 100644 --- a/src/omnisharp/OmnisharpManager.ts +++ b/src/omnisharp/OmnisharpManager.ts @@ -20,10 +20,10 @@ export class OmnisharpManager { private platformInfo: PlatformInformation) { } - public async GetOmniSharpLaunchInfo(omnisharpPath: string, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { + public async GetOmniSharpLaunchInfo(defaultOmnisharpVersion: string, omnisharpPath: string, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise { if (!omnisharpPath) { // If omnisharpPath was not specified, return the default path. - let basePath = path.resolve(extensionPath, '.omnisharp'); + let basePath = path.resolve(extensionPath, '.omnisharp', defaultOmnisharpVersion); return this.GetLaunchInfo(this.platformInfo, basePath); } diff --git a/src/omnisharp/server.ts b/src/omnisharp/server.ts index d55c828e7d..c51146786b 100644 --- a/src/omnisharp/server.ts +++ b/src/omnisharp/server.ts @@ -68,7 +68,7 @@ module Events { const TelemetryReportingDelay = 2 * 60 * 1000; // two minutes const serverUrl = "https://roslynomnisharp.blob.core.windows.net"; -const installPath = ".omnisharp/experimental"; +const installPath = ".omnisharp"; const latestVersionFileServerPath = 'releases/versioninfo.txt'; export class OmniSharpServer { @@ -91,9 +91,9 @@ export class OmniSharpServer { private updateProjectDebouncer = new Subject(); private firstUpdateProject: boolean; - constructor(private vscode: vscode, networkSettingsProvider: NetworkSettingsProvider, private eventStream: EventStream, packageJSON: any, private platformInfo: PlatformInformation) { + constructor(private vscode: vscode, networkSettingsProvider: NetworkSettingsProvider, private eventStream: EventStream, private packageJSON: any, private platformInfo: PlatformInformation) { this._requestQueue = new RequestQueueCollection(this.eventStream, 8, request => this._makeRequest(request)); - let downloader = new OmnisharpDownloader(networkSettingsProvider, this.eventStream, packageJSON, platformInfo); + let downloader = new OmnisharpDownloader(networkSettingsProvider, this.eventStream, this.packageJSON, platformInfo); this._omnisharpManager = new OmnisharpManager(downloader, platformInfo); this.updateProjectDebouncer.debounceTime(1500).subscribe((event) => { this.updateProjectInfo(); }); this.firstUpdateProject = true; @@ -310,7 +310,7 @@ export class OmniSharpServer { let launchInfo: LaunchInfo; try { let extensionPath = utils.getExtensionPath(); - launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this._options.path, serverUrl, latestVersionFileServerPath, installPath, extensionPath); + launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this.packageJSON.defaults.omniSharp, this._options.path, serverUrl, latestVersionFileServerPath, installPath, extensionPath); } catch (error) { this.eventStream.post(new ObservableEvents.OmnisharpFailure(`Error occured in loading omnisharp from omnisharp.path\nCould not start the server due to ${error.toString()}`, error)); diff --git a/tasks/commandLineArguments.ts b/tasks/commandLineArguments.ts index 41da95d5cc..b74d241d0f 100644 --- a/tasks/commandLineArguments.ts +++ b/tasks/commandLineArguments.ts @@ -8,10 +8,13 @@ import * as minimist from 'minimist'; import * as path from 'path'; -let argv = minimist(process.argv.slice(2)); +let argv = minimist(process.argv.slice(2), { + boolean: ['retainVsix'] +}); -export const commandLineOptions ={ - outputFolder: makePathAbsolute(argv['o']), +export const commandLineOptions = { + retainVsix: !!argv['retainVsix'], + outputFolder: makePathAbsolute(argv['o']), codeExtensionPath: makePathAbsolute(argv['codeExtensionPath']) }; diff --git a/tasks/offlinePackagingTasks.ts b/tasks/offlinePackagingTasks.ts index 725fb69b74..8426d014e7 100644 --- a/tasks/offlinePackagingTasks.ts +++ b/tasks/offlinePackagingTasks.ts @@ -22,6 +22,7 @@ import { PlatformInformation } from '../src/platform'; import { DownloadAndInstallPackages } from '../src/packageManager/PackageManager'; import NetworkSettings from '../src/NetworkSettings'; import { GetRunTimeDependenciesPackages } from '../src/CSharpExtDownloader'; +import { commandLineOptions } from '../tasks/commandLineArguments'; gulp.task('vsix:offline:package', async () => { del.sync(vscodeignorePath); @@ -37,7 +38,14 @@ gulp.task('vsix:offline:package', async () => { }); async function doPackageOffline() { - cleanSync(true); + if (commandLineOptions.retainVsix) { + //if user doesnot want to clean up the existing vsix packages + cleanSync(false); + } + else { + cleanSync(true); + } + util.setExtensionPath(codeExtensionPath); const packageJSON = getPackageJSON(); const name = packageJSON.name; diff --git a/test-plan.md b/test-plan.md index 1831055b4a..7167d7b24d 100644 --- a/test-plan.md +++ b/test-plan.md @@ -101,10 +101,10 @@ The easist way to verify that a project was successfully loaded is to open a .cs #### omnisharp.path Setting this path to any of the values as listed below, should start the OmniSharp server and display the correct OmniSharp path in the `OmniSharp Log`(View --> Output--> OmniSharp Log). - * undefined - OmniSharp server must start using the copy of omnisharp shipped with the extension, that is, the OmniSharp path must be the extension path, followed by .omnisharp followed by the platform-specific executable. + * undefined - OmniSharp server must start using the copy of omnisharp shipped with the extension, that is, the OmniSharp path must be the extension path, followed by .omnisharp followed by the default omnisharp version as present in the package.json and the platform-specific executable. * Some absolute path - OmniSharp server must start using the local copy of OmniSharp pointed to by the path and the same must be displayed as the Omnisharp path. Example:C:\omnisharp-roslyn\artifacts\publish\OmniSharp.Stdio\win7-x64\OmniSharp.exe. - * "" - The specified version must be downloaded and installed (The status of download/install can be seen in the `C#` log). If the installation is successful, the server must start and the OmniSharp path must include the .omnisharp/experimental folder followed by the version name and the executable. Eg: If the version is `1.29.2-beta.60`, the path displayed on Windows should be `.omnisharp/experimental/1.29.2-beta.60/OmniSharp.exe`. - * "latest" - The file containing the information about the latest CI build (https://roslynomnisharp.blob.core.windows.net/releases/versioninfo.txt), must be downloaded and accordingly the latest CI build from the "master" branch of omnisharp-roslyn should be downloaded and installed. If the installation is successful, the server must start and the OmniSharp path must include the .omnisharp/experimental folder followed by the version name and the executable. Eg: If the latest version is `1.29.2-beta.62`, the path displayed on Windows should be `.omnisharp/experimental/1.29.2-beta.62/OmniSharp.exe`. + * "" - The specified version must be downloaded and installed (The status of download/install can be seen in the `C#` log). If the installation is successful, the server must start and the OmniSharp path must include the .omnisharp folder followed by the version name and the executable. Eg: If the version is `1.29.2-beta.60`, the path displayed on Windows should be `.omnisharp/1.29.2-beta.60/OmniSharp.exe`. + * "latest" - The file containing the information about the latest CI build (https://roslynomnisharp.blob.core.windows.net/releases/versioninfo.txt), must be downloaded and accordingly the latest CI build from the "master" branch of omnisharp-roslyn should be downloaded and installed. If the installation is successful, the server must start and the OmniSharp path must include the .omnisharp folder followed by the version name and the executable. Eg: If the latest version is `1.29.2-beta.62`, the path displayed on Windows should be `.omnisharp/1.29.2-beta.62/OmniSharp.exe`. * All the above configurations should work, with and without setting the useMono option on Linux * The above behavior should be exhibited when a new vscode window is opened, as well as if the setting is modified and a "Restart OmniSharp"(Ctrl+Shift+P --> OmniSharp: Restart OmniSharp) is performed. diff --git a/test/featureTests/OmnisharpDownloader.test.ts b/test/featureTests/OmnisharpDownloader.test.ts index 0441d26c96..ce38f94f6f 100644 --- a/test/featureTests/OmnisharpDownloader.test.ts +++ b/test/featureTests/OmnisharpDownloader.test.ts @@ -22,7 +22,7 @@ suite("DownloadAndInstallExperimentalVersion : Gets the version packages, downlo const eventStream = new EventStream(); const downloader = GetTestOmnisharpDownloader(eventStream, platformInfo); const serverUrl = "https://roslynomnisharp.blob.core.windows.net"; - const installPath = ".omnisharp/experimental/"; + const installPath = "somePath"; setup(() => { tmpDir = tmp.dirSync(); diff --git a/test/featureTests/OmnisharpManager.test.ts b/test/featureTests/OmnisharpManager.test.ts index edbe7ae757..a278fd5553 100644 --- a/test/featureTests/OmnisharpManager.test.ts +++ b/test/featureTests/OmnisharpManager.test.ts @@ -20,10 +20,11 @@ const tmp = require('tmp'); suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path depending on the path and useMono option', () => { const platformInfo = new PlatformInformation("win32", "x86"); const serverUrl = "https://roslynomnisharp.blob.core.windows.net"; - const installPath = ".omnisharp/experimental"; + const installPath = "somePath"; const versionFilepathInServer = "releases/testVersionInfo.txt"; const eventStream = new EventStream(); const manager = GetTestOmnisharpManager(eventStream, platformInfo); + const defaultVersion = "0.1.2"; let extensionPath: string; let tmpDir: any; let tmpFile: any; @@ -37,68 +38,68 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin }); test('Throws error if the path is neither an absolute path nor a valid semver, nor the string "latest"', async () => { - expect(manager.GetOmniSharpLaunchInfo("Some incorrect path", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); + expect(manager.GetOmniSharpLaunchInfo(defaultVersion, "Some incorrect path", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); }); test('Throws error when the specified path is null', async () => { - expect(manager.GetOmniSharpLaunchInfo(null, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); + expect(manager.GetOmniSharpLaunchInfo(defaultVersion, null, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); }); test('Throws error when the specified path is empty', async () => { - expect(manager.GetOmniSharpLaunchInfo("", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); + expect(manager.GetOmniSharpLaunchInfo(defaultVersion, "", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); }); test('Throws error when the specified path is an invalid semver', async () => { - expect(manager.GetOmniSharpLaunchInfo("a.b.c", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); + expect(manager.GetOmniSharpLaunchInfo(defaultVersion, "a.b.c", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error); }); test('Returns default paths if no path is specified', async () => { - let launchInfo = await manager.GetOmniSharpLaunchInfo(undefined, serverUrl, versionFilepathInServer, installPath, extensionPath); - launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/OmniSharp.exe')); + let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, undefined, serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/${defaultVersion}/OmniSharp.exe`)); expect(launchInfo.MonoLaunchPath).to.be.undefined; }); test('Returns default paths if no path is specified - Linux ', async () => { let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64")); - let launchInfo = await manager.GetOmniSharpLaunchInfo(undefined, serverUrl, versionFilepathInServer, installPath, extensionPath); - launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/run')); - launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/omnisharp/OmniSharp.exe')); + let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, undefined, serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/${defaultVersion}/run`)); + launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/${defaultVersion}/omnisharp/OmniSharp.exe`)); }); test('Returns the same path if absolute path to an existing file is passed', async () => { tmpFile = tmp.fileSync(); - let launchInfo = await manager.GetOmniSharpLaunchInfo(tmpFile.name, serverUrl, versionFilepathInServer, installPath, extensionPath); + let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, tmpFile.name, serverUrl, versionFilepathInServer, installPath, extensionPath); launchInfo.LaunchPath.should.equal(tmpFile.name); }); test('Installs the latest version and returns the launch path based on the version and platform', async () => { - let launchInfo = await manager.GetOmniSharpLaunchInfo("latest", serverUrl, versionFilepathInServer, installPath, extensionPath); - launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`)); + let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "latest", serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `somePath/1.2.3/OmniSharp.exe`)); expect(launchInfo.MonoLaunchPath).to.be.undefined; }); test('Installs the test version and returns the launch path based on the version and platform', async () => { - let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath); - launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`)); + let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `somePath/1.2.3/OmniSharp.exe`)); expect(launchInfo.MonoLaunchPath).to.be.undefined; }); test('Downloads package from given url and installs them at the specified path', async () => { - await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath); - let exists = await util.fileExists(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/install_check_1.2.3.txt`)); + await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath); + let exists = await util.fileExists(path.resolve(extensionPath, `somePath/1.2.3/install_check_1.2.3.txt`)); exists.should.equal(true); }); test('Downloads package and returns launch path based on platform - on Linux ', async () => { let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64")); - let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath); - launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/run')); - launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/omnisharp/OmniSharp.exe')); + let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath); + launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, 'somePath/1.2.3/run')); + launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, 'somePath/1.2.3/omnisharp/OmniSharp.exe')); }); test('Downloads package and returns launch path based on install path ', async () => { let manager = GetTestOmnisharpManager(eventStream, platformInfo); - let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, "installHere", extensionPath); + let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, "installHere", extensionPath); launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, 'installHere/1.2.3/OmniSharp.exe')); expect(launchInfo.MonoLaunchPath).to.be.undefined; }); diff --git a/test/releaseTests/offlinePackage.test.ts b/test/releaseTests/offlinePackage.test.ts index 64f99faa3f..49d9ba073b 100644 --- a/test/releaseTests/offlinePackage.test.ts +++ b/test/releaseTests/offlinePackage.test.ts @@ -21,6 +21,7 @@ suite("Offline packaging of VSIX", function () { let args: string[] = []; args.push(path.join("node_modules", "gulp", "bin", "gulp.js")); args.push("package:offline"); + args.push("--retainVsix");// do not delete the existing vsix in the repo args.push(`-o`); args.push(tmpDir.name); invokeNode(args);