From 305fc7db65b0a4125b8bcd12475c5cfd5c48a42a Mon Sep 17 00:00:00 2001 From: Joey Robichaud Date: Thu, 15 Aug 2024 14:18:59 -0700 Subject: [PATCH] Update OmniSharp to 1.39.12 --- .vscode/launch.json | 6 +- CHANGELOG.md | 10 ++ package.json | 116 +++++++++--------- src/omnisharp/omnisharpDownloader.ts | 83 ++++++++++++- src/omnisharp/omnisharpManager.ts | 15 ++- src/omnisharp/omnisharpPackageCreator.ts | 2 +- src/packageManager/fileDownloader.ts | 2 +- src/tools/updatePackageDependencies.ts | 4 - .../omnisharpDownloader.test.ts | 2 +- .../omnisharpManager.test.ts | 14 ++- .../omnisharpPackageCreator.test.ts | 4 +- 11 files changed, 172 insertions(+), 86 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 377cb83ac..83fd49e84 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -154,9 +154,9 @@ "args": ["updatePackageDependencies"], "env": { "NEW_DEPS_ID": "OmniSharp", - "NEW_DEPS_URLS": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-x64-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-x86-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-arm64-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-osx-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-win-x64-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-win-arm64-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-musl-x64-net6.0-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-musl-arm64-net6.0-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-x64-net6.0-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-arm64-net6.0-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-osx-x64-net6.0-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-osx-arm64-net6.0-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-win-x64-net6.0-1.39.11.zip,https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-win-arm64-net6.0-1.39.11.zip", - "OLD_DEPS_VERSION": "1.39.10", - "NEW_DEPS_VERSION": "1.39.11" + "NEW_DEPS_URLS": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-x64.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-x86.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-arm64.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-osx.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-win-x64.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-win-arm64.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-musl-x64-net6.0.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-musl-arm64-net6.0.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-x64-net6.0.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-arm64-net6.0.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-osx-x64-net6.0.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-osx-arm64-net6.0.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-win-x64-net6.0.zip,https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-win-arm64-net6.0.zip", + "OLD_DEPS_VERSION": "1.39.11", + "NEW_DEPS_VERSION": "1.39.12" }, "cwd": "${workspaceFolder}" }, diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c979c55c..f9b01e2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ - Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876) # Latest +* Update OmniSharp to 1.39.12 (PR: [#7445](https://github.com/dotnet/vscode-csharp/pull/7445)) + * Update .NET SDKs (PR: [omnisharp-roslyn/#2621](https://github.com/OmniSharp/omnisharp-roslyn/pull/2621)) + * Update Roslyn to 4.12.0-1.24358.3 (PR: [omnisharp-roslyn/#2619](https://github.com/OmniSharp/omnisharp-roslyn/pull/2619)) + * Fix code fix construction (PR: [omnisharp-roslyn/#2620](https://github.com/OmniSharp/omnisharp-roslyn/pull/2620)) + * Remove NuGet.Packaging.Core, as it's an assembly that only contains forwarders (PR: [omnisharp-roslyn/#2610](https://github.com/OmniSharp/omnisharp-roslyn/pull/2610)) + * Fix inlay hints lambdas parameter type null reference exception (PR: [omnisharp-roslyn/#2604](https://github.com/OmniSharp/omnisharp-roslyn/pull/2604)) + * Update SDKs and Roslyn (PR: [omnisharp-roslyn/#2603](https://github.com/OmniSharp/omnisharp-roslyn/pull/2603)) + * Pass project path when performing a restore (PR: [omnisharp-roslyn/#2593](https://github.com/OmniSharp/omnisharp-roslyn/pull/2593)) + +# 2.51.x * Bumped xamltools to 17.12.35403.211 (PR: [#7629](https://github.com/dotnet/vscode-csharp/pull/7629)) * Update Roslyn to 4.13.0-1.24503.11 (PR: [#7618](https://github.com/dotnet/vscode-csharp/pull/7618)) * LSP hover responses escape backticks within inline code (PR: [#75364](https://github.com/dotnet/roslyn/pull/75364)) diff --git a/package.json b/package.json index 619d3f5f3..f009de310 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "defaults": { "roslyn": "4.13.0-1.24503.11", - "omniSharp": "1.39.11", + "omniSharp": "1.39.12", "razor": "9.0.0-preview.24480.1", "razorOmnisharp": "7.0.0-preview.23363.1", "xamlTools": "17.12.35403.211" @@ -178,72 +178,72 @@ { "id": "OmniSharp", "description": "OmniSharp for Windows (.NET 4.7.2 / x64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-win-x64-1.39.11.zip", - "installPath": ".omnisharp/1.39.11", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-win-x64.zip", + "installPath": ".omnisharp/1.39.12", "platforms": [ "win32" ], "architectures": [ "x86_64" ], - "installTestPath": "./.omnisharp/1.39.11/OmniSharp.exe", + "installTestPath": "./.omnisharp/1.39.12/OmniSharp.exe", "platformId": "win-x64", "isFramework": true, - "integrity": "E1AD559974430C9AA81819F1433583B0EE9A977D2DAAE1DE32D4D408503B2867" + "integrity": "A52562B44C9BAA2811F0A617F182A5886BB79BB1532850827D89F173D8C962B6" }, { "id": "OmniSharp", "description": "OmniSharp for Windows (.NET 6 / x64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-win-x64-net6.0-1.39.11.zip", - "installPath": ".omnisharp/1.39.11-net6.0", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-win-x64-net6.0.zip", + "installPath": ".omnisharp/1.39.12-net6.0", "platforms": [ "win32" ], "architectures": [ "x86_64" ], - "installTestPath": "./.omnisharp/1.39.11-net6.0/OmniSharp.dll", + "installTestPath": "./.omnisharp/1.39.12-net6.0/OmniSharp.dll", "platformId": "win-x64", "isFramework": false, - "integrity": "A71FD29E6CACDF41FD44ACB9F8532BE33DBD4CB313513E47A031443F648BDBAB" + "integrity": "21BB3F7D990B6D464A748E9C11731582CAEEAAB87D7F749EDEACFE136A09C13E" }, { "id": "OmniSharp", "description": "OmniSharp for Windows (.NET 4.7.2 / arm64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-win-arm64-1.39.11.zip", - "installPath": ".omnisharp/1.39.11", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-win-arm64.zip", + "installPath": ".omnisharp/1.39.12", "platforms": [ "win32" ], "architectures": [ "arm64" ], - "installTestPath": "./.omnisharp/1.39.11/OmniSharp.exe", + "installTestPath": "./.omnisharp/1.39.12/OmniSharp.exe", "platformId": "win-arm64", "isFramework": true, - "integrity": "D42BB3A146B9DED5C59630708A6FFB0F76B2067B31AE3A6596596AFFCE7D79C9" + "integrity": "E61CFBD416C9099D5710748281A0E07763ABE6D6EC930F31335B008DB6907780" }, { "id": "OmniSharp", "description": "OmniSharp for Windows (.NET 6 / arm64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-win-arm64-net6.0-1.39.11.zip", - "installPath": ".omnisharp/1.39.11-net6.0", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-win-arm64-net6.0.zip", + "installPath": ".omnisharp/1.39.12-net6.0", "platforms": [ "win32" ], "architectures": [ "arm64" ], - "installTestPath": "./.omnisharp/1.39.11-net6.0/OmniSharp.dll", + "installTestPath": "./.omnisharp/1.39.12-net6.0/OmniSharp.dll", "platformId": "win-arm64", "isFramework": false, - "integrity": "FFC67D2A97F8E04161BE2DCA5CE48ECEB1B09A3DD0FCE697122D5B77302FC152" + "integrity": "ECA34E2AEEB1775AAB664C5C06232EFBB57BB2CA6020A63FB92D24A0EE3A6906" }, { "id": "OmniSharp", "description": "OmniSharp for OSX (Mono / x64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-osx-1.39.11.zip", - "installPath": ".omnisharp/1.39.11", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-osx.zip", + "installPath": ".omnisharp/1.39.12", "platforms": [ "darwin" ], @@ -255,48 +255,48 @@ "./mono.osx", "./run" ], - "installTestPath": "./.omnisharp/1.39.11/run", + "installTestPath": "./.omnisharp/1.39.12/run", "platformId": "osx", "isFramework": true, - "integrity": "1E339604AE52F531655B57A1058EB56E5CE0E1311C62B4CE16BE7CD0D265AA50" + "integrity": "645BD54508011CEF386FC765FA9E2DD6F6615120A6F611EF78DB2C41A3634C71" }, { "id": "OmniSharp", "description": "OmniSharp for OSX (.NET 6 / x64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-osx-x64-net6.0-1.39.11.zip", - "installPath": ".omnisharp/1.39.11-net6.0", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-osx-x64-net6.0.zip", + "installPath": ".omnisharp/1.39.12-net6.0", "platforms": [ "darwin" ], "architectures": [ "x86_64" ], - "installTestPath": "./.omnisharp/1.39.11-net6.0/OmniSharp.dll", + "installTestPath": "./.omnisharp/1.39.12-net6.0/OmniSharp.dll", "platformId": "osx-x64", "isFramework": false, - "integrity": "01571AE3B5DF4345E42B1EBD85601A654985590D403F40D2F802ED3204516350" + "integrity": "04A286EA36CE60AD1EBC83E16B114FD6663BDE840C43FD695067268A39B81CB1" }, { "id": "OmniSharp", "description": "OmniSharp for OSX (.NET 6 / arm64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-osx-arm64-net6.0-1.39.11.zip", - "installPath": ".omnisharp/1.39.11-net6.0", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-osx-arm64-net6.0.zip", + "installPath": ".omnisharp/1.39.12-net6.0", "platforms": [ "darwin" ], "architectures": [ "arm64" ], - "installTestPath": "./.omnisharp/1.39.11-net6.0/OmniSharp.dll", + "installTestPath": "./.omnisharp/1.39.12-net6.0/OmniSharp.dll", "platformId": "osx-arm64", "isFramework": false, - "integrity": "9318997071878AB2DD7ECA29F1C797449B6C5454A0CB78BED0D17121BEC37B10" + "integrity": "44A197EBB3FC1AE55209FD3A125F2EDF6327F91A0E1EFC76025B5F7787CC4F94" }, { "id": "OmniSharp", "description": "OmniSharp for Linux (Mono / x86)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-x86-1.39.11.zip", - "installPath": ".omnisharp/1.39.11", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-x86.zip", + "installPath": ".omnisharp/1.39.12", "platforms": [ "linux" ], @@ -308,16 +308,16 @@ "./mono.linux-x86", "./run" ], - "installTestPath": "./.omnisharp/1.39.11/run", + "installTestPath": "./.omnisharp/1.39.12/run", "platformId": "linux-x86", "isFramework": true, - "integrity": "9568941017C31318D893669647042065985A0BA871708DA3688208D50CA7F452" + "integrity": "7C5691CCA9F617FBCCAA687F3624913428F31FF3213F689E25D62E17CBC0C2DE" }, { "id": "OmniSharp", "description": "OmniSharp for Linux (Mono / x64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-x64-1.39.11.zip", - "installPath": ".omnisharp/1.39.11", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-x64.zip", + "installPath": ".omnisharp/1.39.12", "platforms": [ "linux" ], @@ -328,32 +328,32 @@ "./mono.linux-x86_64", "./run" ], - "installTestPath": "./.omnisharp/1.39.11/run", + "installTestPath": "./.omnisharp/1.39.12/run", "platformId": "linux-x64", "isFramework": true, - "integrity": "88B70F9D4D7587562C3F25EC1062E8A8120EBCE7083D56E91D9AE4A6C72E4340" + "integrity": "82997A2EC98CDC213712EE0F96FB5A0A6C0858889D26C6BD7DB2FA1269FD6CBA" }, { "id": "OmniSharp", "description": "OmniSharp for Linux (.NET 6 / x64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-x64-net6.0-1.39.11.zip", - "installPath": ".omnisharp/1.39.11-net6.0", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-x64-net6.0.zip", + "installPath": ".omnisharp/1.39.12-net6.0", "platforms": [ "linux" ], "architectures": [ "x86_64" ], - "installTestPath": "./.omnisharp/1.39.11-net6.0/OmniSharp.dll", + "installTestPath": "./.omnisharp/1.39.12-net6.0/OmniSharp.dll", "platformId": "linux-x64", "isFramework": false, - "integrity": "E58BE0F23DD84F2ACCEA245D7DBB8F9DE6ADEA354D44CB2A3F10D7F1326571D9" + "integrity": "7D65424EEEC4D0C06BAEE22D37465AD9718B626D4E9E9CA0E5FB95862630C049" }, { "id": "OmniSharp", "description": "OmniSharp for Linux (Mono / arm64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-arm64-1.39.11.zip", - "installPath": ".omnisharp/1.39.11", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-arm64.zip", + "installPath": ".omnisharp/1.39.12", "platforms": [ "linux" ], @@ -364,58 +364,58 @@ "./mono.linux-arm64", "./run" ], - "installTestPath": "./.omnisharp/1.39.11/run", + "installTestPath": "./.omnisharp/1.39.12/run", "platformId": "linux-arm64", "isFramework": true, - "integrity": "A10A5595AB0B13BD22495A7278995D9711B12F9EDE04AA3BB29CBE8F175EFABA" + "integrity": "39478AE2072874258CC493055F7332FD9BEC7B3ED1FFF57280EB2D07CAFAE4BD" }, { "id": "OmniSharp", "description": "OmniSharp for Linux (.NET 6 / arm64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-arm64-net6.0-1.39.11.zip", - "installPath": ".omnisharp/1.39.11-net6.0", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-arm64-net6.0.zip", + "installPath": ".omnisharp/1.39.12-net6.0", "platforms": [ "linux" ], "architectures": [ "arm64" ], - "installTestPath": "./.omnisharp/1.39.11-net6.0/OmniSharp.dll", + "installTestPath": "./.omnisharp/1.39.12-net6.0/OmniSharp.dll", "platformId": "linux-arm64", "isFramework": false, - "integrity": "D4794CBA966B9B5D0F731E1606E732D5C231D4B1D345788B837565914D880A0E" + "integrity": "1A009CF2D62D1A6FE1646FFF03FED52633B019B49A71FB3D8CE74406224EA0C5" }, { "id": "OmniSharp", "description": "OmniSharp for Linux musl (.NET 6 / x64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-musl-x64-net6.0-1.39.11.zip", - "installPath": ".omnisharp/1.39.11-net6.0", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-musl-x64-net6.0.zip", + "installPath": ".omnisharp/1.39.12-net6.0", "platforms": [ "linux-musl" ], "architectures": [ "x86_64" ], - "installTestPath": "./.omnisharp/1.39.11-net6.0/OmniSharp.dll", + "installTestPath": "./.omnisharp/1.39.12-net6.0/OmniSharp.dll", "platformId": "linux-musl-x64", "isFramework": false, - "integrity": "E8F924BB793C60B032FADE805030DF8F8F9B62F7FC32BF3B688EEA1B7E94B5DA" + "integrity": "FB97F4B0AB76823272B55CA3134FD5877C5651366CB88C678ED0445E86A8CD35" }, { "id": "OmniSharp", "description": "OmniSharp for Linux musl (.NET 6 / arm64)", - "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.11/omnisharp-linux-musl-arm64-net6.0-1.39.11.zip", - "installPath": ".omnisharp/1.39.11-net6.0", + "url": "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.12/omnisharp-linux-musl-arm64-net6.0.zip", + "installPath": ".omnisharp/1.39.12-net6.0", "platforms": [ "linux-musl" ], "architectures": [ "arm64" ], - "installTestPath": "./.omnisharp/1.39.11-net6.0/OmniSharp.dll", + "installTestPath": "./.omnisharp/1.39.12-net6.0/OmniSharp.dll", "platformId": "linux-musl-arm64", "isFramework": false, - "integrity": "223B58388C0F7226874DCA9053FE10B10739F2E43663DEED3F2F48C892E0D8E6" + "integrity": "9944EBD6EE06BD595BCADD3057CD9BEF4105C3A3952DAE03E54F3114E2E6661F" }, { "id": "Debugger", @@ -5597,4 +5597,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/omnisharp/omnisharpDownloader.ts b/src/omnisharp/omnisharpDownloader.ts index 03be20748..b5103083c 100644 --- a/src/omnisharp/omnisharpDownloader.ts +++ b/src/omnisharp/omnisharpDownloader.ts @@ -14,11 +14,15 @@ import { import { EventStream } from '../eventStream'; import { NetworkSettingsProvider } from '../networkSettings'; import { downloadAndInstallPackages } from '../packageManager/downloadAndInstallPackages'; -import { DownloadFile } from '../packageManager/fileDownloader'; import { getRuntimeDependenciesPackages } from '../tools/runtimeDependencyPackageUtils'; import { getAbsolutePathPackagesToInstall } from '../packageManager/getAbsolutePathPackagesToInstall'; import { isValidDownload } from '../packageManager/isValidDownload'; import { LatestBuildDownloadStart } from './omnisharpLoggingEvents'; +import * as https from 'https'; +import { DownloadFailure } from '../shared/loggingEvents'; +import { NestedError } from '../nestedError'; +import { parse as parseUrl } from 'url'; +import { getProxyAgent } from '../packageManager/proxy'; export class OmnisharpDownloader { public constructor( @@ -66,16 +70,83 @@ export class OmnisharpDownloader { return false; } - public async GetLatestVersion(serverUrl: string, latestVersionFileServerPath: string): Promise { - const description = 'Latest OmniSharp Version Information'; - const url = `${serverUrl}/${latestVersionFileServerPath}`; + public async GetLatestVersion(serverUrl: string): Promise { + const url = `${serverUrl}/releases?per_page=1`; try { this.eventStream.post(new LatestBuildDownloadStart()); - const versionBuffer = await DownloadFile(description, this.eventStream, this.networkSettingsProvider, url); - return versionBuffer.toString('utf8'); + const releases = await this.fetchLatestReleases(url); + const latestRelease = releases[0]; + return latestRelease.tag_name.replace('v', ''); } catch (error) { this.eventStream.post(new InstallationFailure('getLatestVersionInfoFile', error)); throw error; } } + + public async fetchLatestReleases(urlString: string): Promise { + const url = parseUrl(urlString); + const networkSettings = this.networkSettingsProvider(); + const proxy = networkSettings.proxy; + const strictSSL = networkSettings.strictSSL; + const options: https.RequestOptions = { + method: 'GET', + host: url.hostname, + path: url.path, + agent: getProxyAgent(url, proxy, strictSSL), + port: url.port, + headers: { Accept: 'application/vnd.github.v3+json' }, + rejectUnauthorized: strictSSL, + }; + + return new Promise((resolve, reject) => { + const request = https.request(options, (response) => { + if (response.statusCode === 301 || response.statusCode === 302) { + // Redirect - download from new location + if (response.headers.location === undefined) { + this.eventStream.post( + new DownloadFailure( + `Failed to download from ${urlString}. Redirected without location header` + ) + ); + return reject(new NestedError('Missing location')); + } + return resolve(this.fetchLatestReleases(response.headers.location)); + } else if (response.statusCode !== 200) { + // Download failed - print error message + this.eventStream.post( + new DownloadFailure( + `Failed to download from ${urlString}. Error code '${response.statusCode}')` + ) + ); + return reject(new NestedError(response.statusCode!.toString())); // Known to exist because this is from a ClientRequest + } + + let body = ''; + + response.on('data', function (chunk) { + body = body + chunk; + }); + + response.on('end', () => { + resolve(JSON.parse(body)); + }); + + response.on('error', (err) => { + reject( + new NestedError( + `Failed to download from ${urlString}. Error Message: ${err.message || 'NONE'}`, + err + ) + ); + }); + }); + + request.on('error', (err) => { + reject(new NestedError(`Request error: ${err.message || 'NONE'}`, err)); + }); + + // Execute the request + request.end(); + }); + } } diff --git a/src/omnisharp/omnisharpManager.ts b/src/omnisharp/omnisharpManager.ts index 91159a369..56fe7c9e3 100644 --- a/src/omnisharp/omnisharpManager.ts +++ b/src/omnisharp/omnisharpManager.ts @@ -11,16 +11,16 @@ import { PlatformInformation } from '../shared/platform'; import { modernNetVersion } from './omnisharpPackageCreator'; export class OmnisharpManager { - private readonly latestVersionFileServerPath = 'releases/versioninfo.txt'; - private readonly installPath = '.omnisharp'; + private readonly githubRepoUrl = 'https://github.com/OmniSharp/omnisharp-roslyn'; + private readonly githubApiUrl = 'https://api.github.com/repos/OmniSharp/omnisharp-roslyn'; public constructor( private downloader: OmnisharpDownloader, private platformInfo: PlatformInformation, // Only the tests set this. Instead of making this configurable, // we should probably just mock the HTTP requests, not create an entire mock HTTP server. - private serverUrl: string = 'https://roslynomnisharp.blob.core.windows.net' + private serverUrl: string | undefined = undefined ) {} public async GetOmniSharpLaunchPath( @@ -54,7 +54,7 @@ export class OmnisharpManager { } private async InstallLatestAndReturnLaunchInfo(useFramework: boolean, extensionPath: string): Promise { - const version = await this.downloader.GetLatestVersion(this.serverUrl, this.latestVersionFileServerPath); + const version = await this.downloader.GetLatestVersion(this.serverUrl ?? this.githubApiUrl); return await this.InstallVersionAndReturnLaunchInfo(version, useFramework, extensionPath); } @@ -64,7 +64,12 @@ export class OmnisharpManager { extensionPath: string ): Promise { if (semver.valid(version)) { - await this.downloader.DownloadAndInstallOmnisharp(version, useFramework, this.serverUrl, this.installPath); + await this.downloader.DownloadAndInstallOmnisharp( + version, + useFramework, + this.serverUrl ?? this.githubRepoUrl, + this.installPath + ); return this.GetLaunchPathForVersion(version, this.platformInfo, useFramework, extensionPath); } else { throw new Error(`Invalid OmniSharp version - ${version}`); diff --git a/src/omnisharp/omnisharpPackageCreator.ts b/src/omnisharp/omnisharpPackageCreator.ts index ff68e4c26..b530db7d1 100644 --- a/src/omnisharp/omnisharpPackageCreator.ts +++ b/src/omnisharp/omnisharpPackageCreator.ts @@ -53,7 +53,7 @@ function GetPackage( ...inputPackage, integrity: undefined, description: `${inputPackage.description}, Version = ${version}`, - url: `${serverUrl}/releases/${version}/omnisharp-${inputPackage.platformId}${packageSuffix}.zip`, + url: `${serverUrl}/releases/download/v${version}/omnisharp-${inputPackage.platformId}${packageSuffix}.zip`, installPath: `${installPath}/${version}${packageSuffix}`, installTestPath: `./${installPath}/${version}${packageSuffix}/${installBinary}`, }; diff --git a/src/packageManager/fileDownloader.ts b/src/packageManager/fileDownloader.ts index b1535a213..adbe3f75f 100644 --- a/src/packageManager/fileDownloader.ts +++ b/src/packageManager/fileDownloader.ts @@ -129,7 +129,7 @@ async function downloadFile( response.on('error', (err) => { reject( new NestedError( - `Failed to download from ${urlString}. Error Message: ${err.message} || 'NONE'}`, + `Failed to download from ${urlString}. Error Message: ${err.message || 'NONE'}`, err ) ); diff --git a/src/tools/updatePackageDependencies.ts b/src/tools/updatePackageDependencies.ts index f62503abf..b80c4a206 100644 --- a/src/tools/updatePackageDependencies.ts +++ b/src/tools/updatePackageDependencies.ts @@ -259,10 +259,6 @@ function getLowercaseFileNameFromUrl(url: string): string { let fileName = url.substr(index + 1).toLowerCase(); if (fileName.startsWith('omnisharp')) { - // Omnisharp versions are always after the last '-'. - // e.g. we want omnisharp-win-x86 from omnisharp-win-x86-1.39.3.zip - const lastDash = fileName.lastIndexOf('-'); - fileName = fileName.substr(0, lastDash); return fileName; } else if (fileName.startsWith('coreclr-debug')) { // Debugger versions are not contained in the file name. diff --git a/test/omnisharp/omnisharpUnitTests/omnisharpDownloader.test.ts b/test/omnisharp/omnisharpUnitTests/omnisharpDownloader.test.ts index bdfb65f6e..6fd842dc3 100644 --- a/test/omnisharp/omnisharpUnitTests/omnisharpDownloader.test.ts +++ b/test/omnisharp/omnisharpUnitTests/omnisharpDownloader.test.ts @@ -61,7 +61,7 @@ import { modernNetVersion } from '../../../src/omnisharp/omnisharpPackageCreator await server.start(); server.addRequestHandler( 'GET', - `/releases/${version}/omnisharp-win-x64${suffix}.zip`, + `/releases/download/v${version}/omnisharp-win-x64${suffix}.zip`, 200, { 'content-type': 'application/zip', diff --git a/test/omnisharp/omnisharpUnitTests/omnisharpManager.test.ts b/test/omnisharp/omnisharpUnitTests/omnisharpManager.test.ts index c829900ba..6e92ca9a2 100644 --- a/test/omnisharp/omnisharpUnitTests/omnisharpManager.test.ts +++ b/test/omnisharp/omnisharpUnitTests/omnisharpManager.test.ts @@ -87,7 +87,7 @@ describe(OmnisharpManager.name, () => { suffix = useFramework ? '' : `-net${modernNetVersion}`; server.addRequestHandler( 'GET', - `/releases/${testVersion}/omnisharp-${elem.platformId}${suffix}.zip`, + `/releases/download/v${testVersion}/omnisharp-${elem.platformId}${suffix}.zip`, 200, { 'content-type': 'application/zip', @@ -98,17 +98,21 @@ describe(OmnisharpManager.name, () => { server.addRequestHandler( 'GET', - `/releases/versioninfo.txt`, + `/releases`, 200, { - 'content-type': 'application/text', + 'content-type': 'application/json', }, - latestVersion + `[ + { + "tag_name": "v${latestVersion}" + } + ]` ); server.addRequestHandler( 'GET', - `/releases/${latestVersion}/omnisharp-${elem.platformId}${suffix}.zip`, + `/releases/download/v${latestVersion}/omnisharp-${elem.platformId}${suffix}.zip`, 200, { 'content-type': 'application/zip', diff --git a/test/omnisharp/omnisharpUnitTests/omnisharpPackageCreator.test.ts b/test/omnisharp/omnisharpUnitTests/omnisharpPackageCreator.test.ts index 68425752c..033f758ff 100644 --- a/test/omnisharp/omnisharpUnitTests/omnisharpPackageCreator.test.ts +++ b/test/omnisharp/omnisharpUnitTests/omnisharpPackageCreator.test.ts @@ -152,7 +152,7 @@ describe('GetOmnisharpPackage : Output package depends on the input package and '1.1.1', installPath ); - expect(resultPackage.url).toEqual('http://someurl/releases/1.1.1/omnisharp-os-architecture.zip'); + expect(resultPackage.url).toEqual('http://someurl/releases/download/v1.1.1/omnisharp-os-architecture.zip'); }); test('Download url is calculated using server url and version (useFramework: false)', () => { @@ -167,7 +167,7 @@ describe('GetOmnisharpPackage : Output package depends on the input package and installPath ); expect(resultPackage.url).toEqual( - `http://someurl/releases/1.1.1/omnisharp-os-architecture-net${modernNetVersion}.zip` + `http://someurl/releases/download/v1.1.1/omnisharp-os-architecture-net${modernNetVersion}.zip` ); }); });