@@ -8,7 +8,7 @@ import { PackageInstallation, LogPlatformInfo, InstallationSuccess } from './sha
88import { EventStream } from './eventStream' ;
99import { getRuntimeDependenciesPackages } from './tools/runtimeDependencyPackageUtils' ;
1010import { getAbsolutePathPackagesToInstall } from './packageManager/getAbsolutePathPackagesToInstall' ;
11- import { DependencyInstallationResults , IInstallDependencies } from './packageManager/IInstallDependencies' ;
11+ import { DependencyInstallationStatus , IInstallDependencies } from './packageManager/IInstallDependencies' ;
1212import { AbsolutePathPackage } from './packageManager/absolutePathPackage' ;
1313
1414export async function installRuntimeDependencies (
@@ -19,31 +19,39 @@ export async function installRuntimeDependencies(
1919 platformInfo : PlatformInformation ,
2020 useFramework : boolean ,
2121 requiredPackageIds : string [ ]
22- ) : Promise < DependencyInstallationResults > {
22+ ) : Promise < DependencyInstallationStatus > {
2323 const runTimeDependencies = getRuntimeDependenciesPackages ( packageJSON ) ;
2424 const packagesToInstall = await getAbsolutePathPackagesToInstall ( runTimeDependencies , platformInfo , extensionPath ) ;
25+
26+ // PackagesToInstall will only return packages that are not already installed. However,
27+ // we need to return the installation status of all required packages, so we need to
28+ // track which required packages are already installed, so that we can return true for them.
29+ const installedPackages = requiredPackageIds . filter (
30+ ( id ) => packagesToInstall . find ( ( pkg ) => pkg . id === id ) === undefined
31+ ) ;
32+ const installedPackagesResults = installedPackages . reduce ( ( acc , id ) => ( { ...acc , [ id ] : true } ) , { } ) ;
33+
2534 const filteredPackages = filterOmniSharpPackage ( packagesToInstall , useFramework ) ;
2635 const filteredRequiredPackages = filteredRequiredPackage ( requiredPackageIds , filteredPackages ) ;
2736
28- if ( filteredRequiredPackages . length > 0 ) {
29- eventStream . post ( new PackageInstallation ( 'C# dependencies' ) ) ;
30- // Display platform information and RID
31- eventStream . post ( new LogPlatformInfo ( platformInfo ) ) ;
37+ if ( filteredRequiredPackages . length === 0 ) {
38+ return installedPackagesResults ;
39+ }
3240
33- const installationResults = await installDependencies ( filteredRequiredPackages ) ;
41+ eventStream . post ( new PackageInstallation ( 'C# dependencies' ) ) ;
42+ // Display platform information and RID
43+ eventStream . post ( new LogPlatformInfo ( platformInfo ) ) ;
3444
35- const failedPackages = Object . entries ( installationResults )
36- . filter ( ( [ , installed ] ) => ! installed )
37- . map ( ( [ name ] ) => name ) ;
38- if ( failedPackages . length === 0 ) {
39- eventStream . post ( new InstallationSuccess ( ) ) ;
40- }
45+ const installationResults = await installDependencies ( filteredRequiredPackages ) ;
4146
42- return installationResults ;
47+ const failedPackages = Object . entries ( installationResults )
48+ . filter ( ( [ , installed ] ) => ! installed )
49+ . map ( ( [ name ] ) => name ) ;
50+ if ( failedPackages . length === 0 ) {
51+ eventStream . post ( new InstallationSuccess ( ) ) ;
4352 }
4453
45- // There was nothing to install
46- return { } ;
54+ return { ...installedPackagesResults , ...installationResults } ;
4755}
4856
4957function filterOmniSharpPackage ( packages : AbsolutePathPackage [ ] , useFramework : boolean ) {
0 commit comments