src/vs/platform/extensionManagement/node/extensionManagementService.ts/ExtensionManagementService/runInstallGalleryExtensionTask
class ExtensionManagementService:	private async runInstallGalleryExtensionTask(installExtensionTask: InstallExtensionTask, options: InstallOptions): Promise<InstallResult> {
		if (options.donotIncludePackAndDependencies) {
			this.logService.info('Installing the extension without checking dependencies and pack', installExtensionTask.extension.identifier.id);
			return installExtensionTask.run();
		}

		const extensionsToInstallMap = new Map<string, { task: InstallExtensionTask, manifest: IExtensionManifest }>();
		const installResults: InstallResult[] = [];

		try {
			const manifest = await this.galleryService.getManifest(installExtensionTask.extension, CancellationToken.None);
			if (manifest === null) {
				const error = new ExtensionManagementError(`Missing manifest for extension ${installExtensionTask.extension.identifier.id}`, INSTALL_ERROR_VALIDATING);
				this.logService.error(`Failed to install extension:`, installExtensionTask.extension.identifier.id, error.message);
				throw error;
			}
			extensionsToInstallMap.set(installExtensionTask.extension.identifier.id.toLowerCase(), { task: installExtensionTask, manifest });

			const allDepsAndPackExtensionsToInstall = await this.getAllDepsAndPackExtensionsToInstall(installExtensionTask.extension.identifier, manifest, CancellationToken.None);
			let installExtensionHasDependents: boolean = false;
			for (const { gallery, manifest } of allDepsAndPackExtensionsToInstall) {
				installExtensionHasDependents = installExtensionHasDependents || !!manifest.extensionDependencies?.some(id => areSameExtensions({ id }, installExtensionTask.extension.identifier));
				if (this.installingExtensions.has(new ExtensionIdentifierWithVersion(gallery.identifier, gallery.version).key())) {
					this.logService.info('Extension is already requested to install', gallery.identifier.id);
				} else {
					const task = this.createInstallFromGalleryExtensionTask(gallery, { ...options, donotIncludePackAndDependencies: true });
					extensionsToInstallMap.set(gallery.identifier.id.toLowerCase(), { task, manifest });
				}
			}

			while (extensionsToInstallMap.size) {
				const extensionsWithoutDepsToInstall = [...extensionsToInstallMap.values()].filter(({ manifest }) => !manifest.extensionDependencies?.some(id => extensionsToInstallMap.has(id.toLowerCase())));
				let extensionsToInstall;
				if (extensionsWithoutDepsToInstall.length) {
					extensionsToInstall = extensionsToInstallMap.size === 1 ? extensionsWithoutDepsToInstall
						/* If the main extension has no dependents remove it and install it at the end */
						: extensionsWithoutDepsToInstall.filter(({ task }) => !(task === installExtensionTask && !installExtensionHasDependents));
				} else {
					this.logService.info('Found extensions with circular dependencies', extensionsWithoutDepsToInstall.map(({ task }) => task.extension.identifier.id));
					extensionsToInstall = [...extensionsToInstallMap.values()];
				}
				await Promise.all(extensionsToInstall.map(async ({ task }) => {
					installResults.push(await task.run());
					extensionsToInstallMap.delete(task.extension.identifier.id.toLowerCase());
				}));
			}

			const installResult = installResults.find(({ local }) => areSameExtensions(local.identifier, installExtensionTask.extension.identifier));
			if (installResult) {
				return installResult;
			}

			throw new Error('Extension is not installed');

		} catch (error) {
			if (extensionsToInstallMap.size) {
				extensionsToInstallMap.forEach(({ task }) => task.cancel());
			} else {
				installExtensionTask.cancel();
			}
			throw error;
		}

	}