src/vs/platform/extensionManagement/node/extensionManagementService.ts/ExtensionManagementService/install
class ExtensionManagementService:	async install(vsix: URI, options: InstallVSIXOptions = {}): Promise<ILocalExtension> {
		this.logService.trace('ExtensionManagementService#install', vsix.toString());
		return createCancelablePromise(async token => {

			const downloadLocation = await this.downloadVsix(vsix);
			const zipPath = path.resolve(downloadLocation.fsPath);

			const manifest = await getManifest(zipPath);
			const identifier = { id: getGalleryExtensionId(manifest.publisher, manifest.name) };
			let operation: InstallOperation = InstallOperation.Install;
			if (manifest.engines && manifest.engines.vscode && !isEngineValid(manifest.engines.vscode, product.version, product.date)) {
				throw new Error(nls.localize('incompatible', "Unable to install extension '{0}' as it is not compatible with VS Code '{1}'.", identifier.id, product.version));
			}

			const identifierWithVersion = new ExtensionIdentifierWithVersion(identifier, manifest.version);
			const installedExtensions = await this.getInstalled(ExtensionType.User);
			const existing = installedExtensions.find(i => areSameExtensions(identifier, i.identifier));
			if (existing) {
				options.isMachineScoped = options.isMachineScoped || existing.isMachineScoped;
				options.isBuiltin = options.isBuiltin || existing.isBuiltin;
				operation = InstallOperation.Update;
				if (identifierWithVersion.equals(new ExtensionIdentifierWithVersion(existing.identifier, existing.manifest.version))) {
					try {
						await this.extensionsScanner.removeExtension(existing, 'existing');
					} catch (e) {
						throw new Error(nls.localize('restartCode', "Please restart VS Code before reinstalling {0}.", manifest.displayName || manifest.name));
					}
				} else if (semver.gt(existing.manifest.version, manifest.version)) {
					await this.uninstallExtension(existing);
				}
			} else {
				// Remove the extension with same version if it is already uninstalled.
				// Installing a VSIX extension shall replace the existing extension always.
				const existing = await this.unsetUninstalledAndGetLocal(identifierWithVersion);
				if (existing) {
					try {
						await this.extensionsScanner.removeExtension(existing, 'existing');
					} catch (e) {
						throw new Error(nls.localize('restartCode', "Please restart VS Code before reinstalling {0}.", manifest.displayName || manifest.name));
					}
				}
			}

			this.logService.info('Installing the extension:', identifier.id);
			this._onInstallExtension.fire({ identifier, zipPath });

			let metadata: IGalleryMetadata | undefined;
			try {
				metadata = await this.getGalleryMetadata(getGalleryExtensionId(manifest.publisher, manifest.name));
			} catch (e) { /* Ignore */ }

			try {
				const local = await this.installFromZipPath(identifierWithVersion, zipPath, options.installOnlyNewlyAddedFromExtensionPack ? existing : undefined, { ...(metadata || {}), ...options }, options, operation, token);
				this.logService.info('Successfully installed the extension:', identifier.id);
				return local;
			} catch (e) {
				this.logService.error('Failed to install the extension:', identifier.id, e.message);
				throw e;
			}
		});
	}