1+ using System . Collections . ObjectModel ;
2+
13using ExtensionManager . Manifest ;
24using ExtensionManager . UI ;
35using ExtensionManager . UI . Worker ;
46using ExtensionManager . VisualStudio . Documents ;
57using ExtensionManager . VisualStudio . Extensions ;
68using ExtensionManager . VisualStudio . MessageBox ;
9+ using ExtensionManager . VisualStudio . Solution ;
710
811namespace ExtensionManager . Features . Export ;
912
@@ -17,15 +20,17 @@ public sealed class Args
1720 public IVSExtensions Extensions { get ; }
1821 public IDialogService DialogService { get ; }
1922 public IManifestService ManifestService { get ; }
23+ public IVSSolutions Solutions { get ; }
2024
21- public Args ( IThisVsixInfo vsixInfo , IVSDocuments documents , IVSMessageBox messageBox , IVSExtensions extensions , IDialogService dialogService , IManifestService manifestService )
25+ public Args ( IThisVsixInfo vsixInfo , IVSDocuments documents , IVSMessageBox messageBox , IVSExtensions extensions , IDialogService dialogService , IManifestService manifestService , IVSSolutions solutions )
2226 {
2327 VsixInfo = vsixInfo ;
2428 Documents = documents ;
2529 MessageBox = messageBox ;
2630 Extensions = extensions ;
2731 DialogService = dialogService ;
2832 ManifestService = manifestService ;
33+ Solutions = solutions ;
2934 }
3035 }
3136
@@ -37,6 +42,7 @@ public Args(IThisVsixInfo vsixInfo, IVSDocuments documents, IVSMessageBox messag
3742 protected IVSExtensions Extensions => _args . Extensions ;
3843 protected IDialogService DialogService => _args . DialogService ;
3944 protected IManifestService ManifestService => _args . ManifestService ;
45+ protected IVSSolutions Solutions => _args . Solutions ;
4046
4147 protected ExportFeatureBase ( Args args )
4248 {
@@ -45,15 +51,31 @@ protected ExportFeatureBase(Args args)
4551
4652 public async Task ExecuteAsync ( )
4753 {
48- var manifest = ManifestService . CreateNew ( ) ;
54+ IManifest manifest ;
55+
56+ var vsextFile = await Solutions . GetCurrentSolutionExtensionsManifestFilePathAsync ( MessageBox ) . ConfigureAwait ( false ) ;
57+
58+ if ( vsextFile != null && ! string . IsNullOrEmpty ( vsextFile ) )
59+ {
60+ // Attempt to read manifest from the found .vsext file
61+ manifest = await ManifestService . ReadAsync ( vsextFile ) . ConfigureAwait ( false ) ;
62+ }
63+ else
64+ {
65+ // No .vsext found: create new manifest
66+ manifest = ManifestService . CreateNew ( ) ;
67+ }
68+
4969 var installedExtensions = await Extensions . GetInstalledExtensionsAsync ( ) . ConfigureAwait ( false ) ;
5070
5171 var installedExtensionsList = installedExtensions as List < IVSExtension >
5272 ?? installedExtensions . ToList ( ) ;
5373
5474 installedExtensionsList . RemoveAll ( vsix => vsix . Id == VsixInfo . Id ) ;
5575
56- await ShowExportDialogAsync ( manifest , this , installedExtensions ) ;
76+ var selectedExtensions = manifest . Extensions ;
77+
78+ await ShowExportDialogAsync ( manifest , this , installedExtensions , new ReadOnlyCollection < IVSExtension > ( selectedExtensions ) ) ;
5779 }
5880
5981 async Task IExportWorker . ExportAsync ( IManifest manifest , IProgress < ProgressStep < ExportStep > > progress , CancellationToken cancellationToken )
@@ -71,6 +93,7 @@ async Task IExportWorker.ExportAsync(IManifest manifest, IProgress<ProgressStep<
7193 }
7294
7395 protected abstract Task < string ? > GetFilePathAsync ( ) ;
74- protected abstract Task ShowExportDialogAsync ( IManifest manifest , IExportWorker worker , IReadOnlyCollection < IVSExtension > installedExtensions ) ;
96+ protected abstract Task ShowExportDialogAsync ( IManifest manifest , IExportWorker worker , IReadOnlyCollection < IVSExtension > installedExtensions , IReadOnlyCollection < IVSExtension > selectedExtensions ) ;
7597 protected abstract Task OnManifestWrittenAsync ( string filePath ) ;
7698}
99+
0 commit comments