diff --git a/src/vs/platform/extensionManagement/node/extensionManagementService.ts b/src/vs/platform/extensionManagement/node/extensionManagementService.ts index c7137910f44..905dec7cd90 100644 --- a/src/vs/platform/extensionManagement/node/extensionManagementService.ts +++ b/src/vs/platform/extensionManagement/node/extensionManagementService.ts @@ -599,7 +599,13 @@ export class ExtensionsScanner extends Disposable { metadata = { ...source?.metadata, ...metadata }; if (target) { - await this.extensionsProfileScannerService.updateMetadata([[extension, { ...target.metadata, ...metadata }]], toProfileLocation); + if (this.uriIdentityService.extUri.isEqual(target.location, extension.location)) { + await this.extensionsProfileScannerService.updateMetadata([[extension, { ...target.metadata, ...metadata }]], toProfileLocation); + } else { + const targetExtension = await this.scanLocalExtension(target.location, extension.type, toProfileLocation); + await this.extensionsProfileScannerService.removeExtensionFromProfile(targetExtension, toProfileLocation); + await this.extensionsProfileScannerService.addExtensionsToProfile([[extension, { ...target.metadata, ...metadata }]], toProfileLocation); + } } else { await this.extensionsProfileScannerService.addExtensionsToProfile([[extension, metadata]], toProfileLocation); }