diff options
Diffstat (limited to 'src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs')
| -rw-r--r-- | src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs b/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs index 68bfd8d7..7de40fb8 100644 --- a/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs +++ b/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs | |||
| @@ -1,19 +1,26 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | 2 | ||
| 3 | namespace WixToolset.Bind | 3 | namespace WixToolset.Core.Bind |
| 4 | { | 4 | { |
| 5 | using System.Collections.Generic; | ||
| 5 | using System.IO; | 6 | using System.IO; |
| 7 | using System.Linq; | ||
| 6 | using System.Reflection; | 8 | using System.Reflection; |
| 7 | using WixToolset.Data; | 9 | using WixToolset.Data; |
| 10 | using WixToolset.Extensibility; | ||
| 8 | 11 | ||
| 9 | internal class ExtractEmbeddedFilesCommand : ICommand | 12 | public class ExtractEmbeddedFilesCommand |
| 10 | { | 13 | { |
| 11 | public ExtractEmbeddedFiles FilesWithEmbeddedFiles { private get; set; } | 14 | public IEnumerable<IExpectedExtractFile> FilesWithEmbeddedFiles { private get; set; } |
| 12 | 15 | ||
| 13 | public void Execute() | 16 | public void Execute() |
| 14 | { | 17 | { |
| 15 | foreach (var baseUri in this.FilesWithEmbeddedFiles.Uris) | 18 | var group = this.FilesWithEmbeddedFiles.GroupBy(e => e.Uri); |
| 19 | |||
| 20 | foreach (var expectedEmbeddedFileByUri in group) | ||
| 16 | { | 21 | { |
| 22 | var baseUri = expectedEmbeddedFileByUri.Key; | ||
| 23 | |||
| 17 | Stream stream = null; | 24 | Stream stream = null; |
| 18 | try | 25 | try |
| 19 | { | 26 | { |
| @@ -34,18 +41,20 @@ namespace WixToolset.Bind | |||
| 34 | 41 | ||
| 35 | using (FileStructure fs = FileStructure.Read(stream)) | 42 | using (FileStructure fs = FileStructure.Read(stream)) |
| 36 | { | 43 | { |
| 37 | foreach (var embeddedFile in this.FilesWithEmbeddedFiles.GetExtractFilesForUri(baseUri)) | 44 | var uniqueIndicies = new SortedSet<int>(); |
| 45 | |||
| 46 | foreach (var embeddedFile in expectedEmbeddedFileByUri) | ||
| 38 | { | 47 | { |
| 39 | fs.ExtractEmbeddedFile(embeddedFile.EmbeddedFileIndex, embeddedFile.OutputPath); | 48 | if (uniqueIndicies.Add(embeddedFile.EmbeddedFileIndex)) |
| 49 | { | ||
| 50 | fs.ExtractEmbeddedFile(embeddedFile.EmbeddedFileIndex, embeddedFile.OutputPath); | ||
| 51 | } | ||
| 40 | } | 52 | } |
| 41 | } | 53 | } |
| 42 | } | 54 | } |
| 43 | finally | 55 | finally |
| 44 | { | 56 | { |
| 45 | if (null != stream) | 57 | stream?.Close(); |
| 46 | { | ||
| 47 | stream.Close(); | ||
| 48 | } | ||
| 49 | } | 58 | } |
| 50 | } | 59 | } |
| 51 | } | 60 | } |
