66import { PlatformInformation } from './platform' ;
77import { PackageInstallation , LogPlatformInfo , InstallationSuccess } from './omnisharp/loggingEvents' ;
88import { EventStream } from './EventStream' ;
9- import { DownloadAndInstallPackages } from './packageManager/PackageManager' ;
10- import { Package } from './packageManager/Package' ;
9+ import { downloadAndInstallPackages1 } from './packageManager/PackageManager' ;
1110import { NetworkSettingsProvider } from './NetworkSettings' ;
11+ import { getRuntimeDependenciesPackages } from './tools/RuntimeDependencyPackageUtils' ;
12+ import { AbsolutePathPackage } from './packageManager/AbsolutePathPackage' ;
13+ import { filterPackages } from './packageManager/PackageFilterer' ;
1214
13- /*
14- * Class used to download the runtime dependencies of the C# Extension
15- */
16- export class CSharpExtDownloader {
17-
18- public constructor (
19- private networkSettingsProvider : NetworkSettingsProvider ,
20- private eventStream : EventStream ,
21- private packageJSON : any ,
22- private platformInfo : PlatformInformation ,
23- private extensionPath : string ) {
24- }
25-
26- public async installRuntimeDependencies ( ) : Promise < boolean > {
27- this . eventStream . post ( new PackageInstallation ( "C# dependencies" ) ) ;
28-
15+ export async function installRuntimeDependencies ( packageJSON : any , extensionPath : string , networkSettingsProvider : NetworkSettingsProvider , eventStream : EventStream , platformInfo : PlatformInformation ) : Promise < boolean > {
16+ let runTimeDependencies = getRuntimeDependenciesPackages ( packageJSON ) ;
17+ let absolutePathPackages = runTimeDependencies . map ( pkg => AbsolutePathPackage . getAbsolutePathPackage ( pkg , extensionPath ) ) ;
18+ let packagesToInstall = await filterPackages ( absolutePathPackages , platformInfo ) ;
19+ if ( packagesToInstall && packagesToInstall . length > 0 ) {
20+ eventStream . post ( new PackageInstallation ( "C# dependencies" ) ) ;
2921 try {
3022 // Display platform information and RID
31- this . eventStream . post ( new LogPlatformInfo ( this . platformInfo ) ) ;
32- let runTimeDependencies = GetRunTimeDependenciesPackages ( this . packageJSON ) ;
33- await DownloadAndInstallPackages ( runTimeDependencies , this . networkSettingsProvider , this . platformInfo , this . eventStream , this . extensionPath ) ;
34- this . eventStream . post ( new InstallationSuccess ( ) ) ;
23+ eventStream . post ( new LogPlatformInfo ( platformInfo ) ) ;
24+ await downloadAndInstallPackages1 ( packagesToInstall , networkSettingsProvider , eventStream ) ;
25+ eventStream . post ( new InstallationSuccess ( ) ) ;
3526 return true ;
3627 }
3728 catch ( error ) {
3829 return false ;
3930 }
4031 }
41- }
4232
43- export function GetRunTimeDependenciesPackages ( packageJSON : any ) : Package [ ] {
44- if ( packageJSON . runtimeDependencies ) {
45- return JSON . parse ( JSON . stringify ( < Package [ ] > packageJSON . runtimeDependencies ) ) ;
46- }
33+ //All the required packages are already downloaded and installed
34+ return true ;
35+ }
4736
48- throw new Error ( "No runtime dependencies found" ) ;
49- }
0 commit comments