Skip to content

Commit ccf9531

Browse files
Thieumloop8ack
authored andcommitted
allow recovering of already exported extension
allow recovering of already exported extension in manage extensions of a specific solution. Otherwise every export is destructive, with existing vsext.
1 parent e12d66f commit ccf9531

8 files changed

Lines changed: 49 additions & 22 deletions

File tree

src/ExtensionManager.UI/DialogService.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@ public DialogService(IVSThreads threads)
4646
}
4747
}
4848

49-
public Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions)
50-
=> ShowExportDialogAsync(worker, manifest, installedExtensions, forSolution: false);
51-
public Task ShowExportForSolutionDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions)
52-
=> ShowExportDialogAsync(worker, manifest, installedExtensions, forSolution: true);
53-
private async Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, bool forSolution)
49+
public Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions)
50+
=> ShowExportDialogAsync(worker, manifest, installedExtensions, selectedExtensions, forSolution: false);
51+
public Task ShowExportForSolutionDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions)
52+
=> ShowExportDialogAsync(worker, manifest, installedExtensions, selectedExtensions, forSolution: true);
53+
private async Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions, bool forSolution)
5454
{
5555
var vm = new ExportDialogViewModel(worker, manifest, forSolution);
5656

57+
var selectedIds = new HashSet<string>(selectedExtensions.Select(se => se.Id));
58+
5759
foreach (var ext in installedExtensions)
58-
vm.Extensions.Add(new(ext));
60+
vm.Extensions.Add(new(ext) { IsSelected = selectedIds.Contains(ext.Id) });
5961

6062
await ShowInstallExportDialogAsync(vm);
6163
}

src/ExtensionManager.UI/IDialogService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public interface IDialogService
99
Task<string?> ShowSaveVsextFileDialogAsync();
1010
Task<string?> ShowOpenVsextFileDialogAsync();
1111

12-
Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions);
13-
Task ShowExportForSolutionDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions);
12+
Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions);
13+
Task ShowExportForSolutionDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions);
1414
Task ShowInstallDialogAsync(IInstallWorker worker, IManifest manifest, IReadOnlyCollection<VSExtensionToInstall> extensions);
1515
Task ShowInstallForSolutionDialogAsync(IInstallWorker worker, IManifest manifest, IReadOnlyCollection<VSExtensionToInstall> extensions);
1616
}

src/ExtensionManager.Vsix.VS2022/ExtensionManager.Vsix.VS2022.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,20 @@
9999
</ItemGroup>
100100
<ItemGroup>
101101
<PackageReference Include="Community.VisualStudio.Toolkit.17">
102-
<Version>17.0.507</Version>
102+
<Version>17.0.549</Version>
103103
</PackageReference>
104104
<PackageReference Include="Microsoft.VisualStudio.SDK">
105105
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
106106
<ExcludeAssets>runtime</ExcludeAssets>
107107
<Version>17.6.36389</Version>
108108
</PackageReference>
109109
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop">
110-
<Version>3.6.2115</Version>
110+
<Version>3.14.2075</Version>
111111
</PackageReference>
112112
<PackageReference Include="Microsoft.VSSDK.BuildTools">
113113
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
114114
<PrivateAssets>all</PrivateAssets>
115-
<Version>17.6.2164</Version>
115+
<Version>17.14.2120</Version>
116116
</PackageReference>
117117
<PackageReference Include="System.Collections.Immutable">
118118
<Version>8.0.0</Version>

src/ExtensionManager.Vsix.VS2022/source.extension.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ------------------------------------------------------------------------------
22
// <auto-generated>
3-
// This file was generated by VSIX Synchronizer
3+
// This file was generated by VSIX Synchronizer 1.0.45
4+
// Available from https://marketplace.visualstudio.com/items?itemName=MadsKristensen.VsixSynchronizer64
45
// </auto-generated>
56
// ------------------------------------------------------------------------------
67
namespace ExtensionManager
@@ -14,5 +15,6 @@ internal sealed partial class Vsix
1415
public const string Version = "9.9.9999";
1516
public const string Author = "Loop8ack";
1617
public const string Tags = "extension pack, vsix";
18+
public const bool IsPreview = false;
1719
}
1820
}

src/ExtensionManager.Vsix.VS2022/source.extension.vsixmanifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
44
<Identity Id="3d183c28-64c6-4efb-a201-50310d65e675" Version="9.9.9999" Language="en-US" Publisher="Loop8ack" />
@@ -11,7 +11,7 @@
1111
<Tags>extension pack, vsix</Tags>
1212
</Metadata>
1313
<Installation AllUsers="true">
14-
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0,18.0)">
14+
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0,19.0)">
1515
<ProductArchitecture>amd64</ProductArchitecture>
1616
</InstallationTarget>
1717
</Installation>

src/ExtensionManager/Features/Export/ExportFeature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public ExportFeature(Args args)
1414
protected override async Task<string?> GetFilePathAsync()
1515
=> await DialogService.ShowSaveVsextFileDialogAsync();
1616

17-
protected override async Task ShowExportDialogAsync(IManifest manifest, IExportWorker worker, IReadOnlyCollection<IVSExtension> extensions)
18-
=> await DialogService.ShowExportDialogAsync(worker, manifest, extensions);
17+
protected override async Task ShowExportDialogAsync(IManifest manifest, IExportWorker worker, IReadOnlyCollection<IVSExtension> extensions, IReadOnlyCollection<IVSExtension> selectedExtensions)
18+
=> await DialogService.ShowExportDialogAsync(worker, manifest, extensions, selectedExtensions);
1919

2020
protected override async Task OnManifestWrittenAsync(string filePath)
2121
=> await Documents.OpenAsync(filePath);

src/ExtensionManager/Features/Export/ExportFeatureBase.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
using System.Collections.ObjectModel;
2+
13
using ExtensionManager.Manifest;
24
using ExtensionManager.UI;
35
using ExtensionManager.UI.Worker;
46
using ExtensionManager.VisualStudio.Documents;
57
using ExtensionManager.VisualStudio.Extensions;
68
using ExtensionManager.VisualStudio.MessageBox;
9+
using ExtensionManager.VisualStudio.Solution;
710

811
namespace 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+

src/ExtensionManager/Features/Export/ExportSolutionFeature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public ExportSolutionFeature(Args args, IVSSolutions solutions)
1818
protected override async Task<string?> GetFilePathAsync()
1919
=> await _solutions.GetCurrentSolutionExtensionsManifestFilePathAsync(MessageBox);
2020

21-
protected override async Task ShowExportDialogAsync(IManifest manifest, IExportWorker worker, IReadOnlyCollection<IVSExtension> installedExtensions)
22-
=> await DialogService.ShowExportForSolutionDialogAsync(worker, manifest, installedExtensions);
21+
protected override async Task ShowExportDialogAsync(IManifest manifest, IExportWorker worker, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions)
22+
=> await DialogService.ShowExportForSolutionDialogAsync(worker, manifest, installedExtensions, selectedExtensions);
2323

2424
protected override async Task OnManifestWrittenAsync(string filePath)
2525
{

0 commit comments

Comments
 (0)