diff options
| author | Rob Mensching <rob@firegiant.com> | 2019-10-25 00:48:35 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2019-10-25 00:53:29 -0700 |
| commit | 9c714a8f1baa6e0130e5cd00cbdca649cebaf6a5 (patch) | |
| tree | ebf26d0e37244f3014e0c4924a29af7f7e56e2f2 /src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs | |
| parent | 87580cbe111a8df836231a0192dee674cf482f08 (diff) | |
| download | wix-9c714a8f1baa6e0130e5cd00cbdca649cebaf6a5.tar.gz wix-9c714a8f1baa6e0130e5cd00cbdca649cebaf6a5.tar.bz2 wix-9c714a8f1baa6e0130e5cd00cbdca649cebaf6a5.zip | |
Update to WixOutput file structure to fix embedded file handling
Diffstat (limited to 'src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs')
| -rw-r--r-- | src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs b/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs index d82609db..683c3c50 100644 --- a/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs +++ b/src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs | |||
| @@ -2,10 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Core.Bind | 3 | namespace WixToolset.Core.Bind |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 6 | using System.IO; | ||
| 7 | using System.Linq; | 7 | using System.Linq; |
| 8 | using System.Reflection; | ||
| 9 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 10 | using WixToolset.Extensibility.Data; | 9 | using WixToolset.Extensibility.Data; |
| 11 | 10 | ||
| @@ -26,41 +25,18 @@ namespace WixToolset.Core.Bind | |||
| 26 | { | 25 | { |
| 27 | var baseUri = expectedEmbeddedFileByUri.Key; | 26 | var baseUri = expectedEmbeddedFileByUri.Key; |
| 28 | 27 | ||
| 29 | Stream stream = null; | 28 | using (var wixout = WixOutput.Read(baseUri)) |
| 30 | try | ||
| 31 | { | 29 | { |
| 32 | // If the embedded files are stored in an assembly resource stream (usually | 30 | var uniqueIds = new SortedSet<string>(StringComparer.OrdinalIgnoreCase); |
| 33 | // a .wixlib embedded in a WixExtension). | ||
| 34 | if ("embeddedresource" == baseUri.Scheme) | ||
| 35 | { | ||
| 36 | var assemblyPath = Path.GetFullPath(baseUri.LocalPath); | ||
| 37 | var resourceName = baseUri.Fragment.TrimStart('#'); | ||
| 38 | |||
| 39 | var assembly = Assembly.LoadFile(assemblyPath); | ||
| 40 | stream = assembly.GetManifestResourceStream(resourceName); | ||
| 41 | } | ||
| 42 | else // normal file (usually a binary .wixlib on disk). | ||
| 43 | { | ||
| 44 | stream = File.OpenRead(baseUri.LocalPath); | ||
| 45 | } | ||
| 46 | 31 | ||
| 47 | using (var fs = FileStructure.Read(stream)) | 32 | foreach (var embeddedFile in expectedEmbeddedFileByUri) |
| 48 | { | 33 | { |
| 49 | var uniqueIndicies = new SortedSet<int>(); | 34 | if (uniqueIds.Add(embeddedFile.EmbeddedFileId)) |
| 50 | |||
| 51 | foreach (var embeddedFile in expectedEmbeddedFileByUri) | ||
| 52 | { | 35 | { |
| 53 | if (uniqueIndicies.Add(embeddedFile.EmbeddedFileIndex)) | 36 | wixout.ExtractEmbeddedFile(embeddedFile.EmbeddedFileId, embeddedFile.OutputPath); |
| 54 | { | ||
| 55 | fs.ExtractEmbeddedFile(embeddedFile.EmbeddedFileIndex, embeddedFile.OutputPath); | ||
| 56 | } | ||
| 57 | } | 37 | } |
| 58 | } | 38 | } |
| 59 | } | 39 | } |
| 60 | finally | ||
| 61 | { | ||
| 62 | stream?.Close(); | ||
| 63 | } | ||
| 64 | } | 40 | } |
| 65 | } | 41 | } |
| 66 | } | 42 | } |
