diff options
author | Rob Mensching <rob@firegiant.com> | 2022-03-14 10:27:18 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-03-14 12:50:55 -0700 |
commit | 2a702f736a907febdd03b493437f0bad3f6732af (patch) | |
tree | 6c8c6701947cce3f9da5bb957ab9460b4ece3845 | |
parent | 02b8f1a145724d889f95761390dc6223289764ac (diff) | |
download | wix-2a702f736a907febdd03b493437f0bad3f6732af.tar.gz wix-2a702f736a907febdd03b493437f0bad3f6732af.tar.bz2 wix-2a702f736a907febdd03b493437f0bad3f6732af.zip |
Display warning when extracting bundle from Package Cache
The Package Cache contains stripped bundles which would fail
extraction with an exception. Display a warning instead. Plus do a
touch of code clean up.
Fixes 6315
-rw-r--r-- | src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs | 55 | ||||
-rw-r--r-- | src/wix/WixToolset.Core.Burn/BurnBackendWarnings.cs | 6 | ||||
-rw-r--r-- | src/wix/WixToolset.Core.Burn/CommandLine/ExtractSubcommand.cs | 10 |
3 files changed, 40 insertions, 31 deletions
diff --git a/src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs b/src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs index 933afc77..b30ac48a 100644 --- a/src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs +++ b/src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs | |||
@@ -84,9 +84,9 @@ namespace WixToolset.Core.Burn.Bundles | |||
84 | } | 84 | } |
85 | 85 | ||
86 | Directory.CreateDirectory(outputDirectory); | 86 | Directory.CreateDirectory(outputDirectory); |
87 | string tempCabPath = Path.Combine(tempDirectory, "ux.cab"); | 87 | var tempCabPath = Path.Combine(tempDirectory, "ux.cab"); |
88 | string manifestOriginalPath = Path.Combine(outputDirectory, "0"); | 88 | var manifestOriginalPath = Path.Combine(outputDirectory, "0"); |
89 | string manifestPath = Path.Combine(outputDirectory, "manifest.xml"); | 89 | var manifestPath = Path.Combine(outputDirectory, "manifest.xml"); |
90 | var uxContainerSlot = this.AttachedContainers[0]; | 90 | var uxContainerSlot = this.AttachedContainers[0]; |
91 | 91 | ||
92 | this.binaryReader.BaseStream.Seek(this.UXAddress, SeekOrigin.Begin); | 92 | this.binaryReader.BaseStream.Seek(this.UXAddress, SeekOrigin.Begin); |
@@ -101,20 +101,20 @@ namespace WixToolset.Core.Burn.Bundles | |||
101 | Directory.CreateDirectory(Path.GetDirectoryName(manifestPath)); | 101 | Directory.CreateDirectory(Path.GetDirectoryName(manifestPath)); |
102 | FileSystem.MoveFile(manifestOriginalPath, manifestPath); | 102 | FileSystem.MoveFile(manifestOriginalPath, manifestPath); |
103 | 103 | ||
104 | XmlDocument document = new XmlDocument(); | 104 | var document = new XmlDocument(); |
105 | document.Load(manifestPath); | 105 | document.Load(manifestPath); |
106 | XmlNamespaceManager namespaceManager = new XmlNamespaceManager(document.NameTable); | 106 | var namespaceManager = new XmlNamespaceManager(document.NameTable); |
107 | namespaceManager.AddNamespace("burn", BurnCommon.BurnNamespace); | 107 | namespaceManager.AddNamespace("burn", BurnCommon.BurnNamespace); |
108 | XmlNodeList uxPayloads = document.SelectNodes("/burn:BurnManifest/burn:UX/burn:Payload", namespaceManager); | 108 | var uxPayloads = document.SelectNodes("/burn:BurnManifest/burn:UX/burn:Payload", namespaceManager); |
109 | XmlNodeList payloads = document.SelectNodes("/burn:BurnManifest/burn:Payload", namespaceManager); | 109 | var payloads = document.SelectNodes("/burn:BurnManifest/burn:Payload", namespaceManager); |
110 | 110 | ||
111 | foreach (XmlNode uxPayload in uxPayloads) | 111 | foreach (XmlNode uxPayload in uxPayloads) |
112 | { | 112 | { |
113 | XmlNode sourcePathNode = uxPayload.Attributes.GetNamedItem("SourcePath"); | 113 | var sourcePathNode = uxPayload.Attributes.GetNamedItem("SourcePath"); |
114 | XmlNode filePathNode = uxPayload.Attributes.GetNamedItem("FilePath"); | 114 | var filePathNode = uxPayload.Attributes.GetNamedItem("FilePath"); |
115 | 115 | ||
116 | string sourcePath = Path.Combine(outputDirectory, sourcePathNode.Value); | 116 | var sourcePath = Path.Combine(outputDirectory, sourcePathNode.Value); |
117 | string destinationPath = Path.Combine(outputDirectory, filePathNode.Value); | 117 | var destinationPath = Path.Combine(outputDirectory, filePathNode.Value); |
118 | 118 | ||
119 | Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)); | 119 | Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)); |
120 | FileSystem.MoveFile(sourcePath, destinationPath); | 120 | FileSystem.MoveFile(sourcePath, destinationPath); |
@@ -122,18 +122,18 @@ namespace WixToolset.Core.Burn.Bundles | |||
122 | 122 | ||
123 | foreach (XmlNode payload in payloads) | 123 | foreach (XmlNode payload in payloads) |
124 | { | 124 | { |
125 | XmlNode packagingNode = payload.Attributes.GetNamedItem("Packaging"); | 125 | var packagingNode = payload.Attributes.GetNamedItem("Packaging"); |
126 | 126 | ||
127 | string packaging = packagingNode.Value; | 127 | var packaging = packagingNode.Value; |
128 | 128 | ||
129 | if (packaging.Equals("embedded", StringComparison.OrdinalIgnoreCase)) | 129 | if (packaging.Equals("embedded", StringComparison.OrdinalIgnoreCase)) |
130 | { | 130 | { |
131 | XmlNode sourcePathNode = payload.Attributes.GetNamedItem("SourcePath"); | 131 | var sourcePathNode = payload.Attributes.GetNamedItem("SourcePath"); |
132 | XmlNode filePathNode = payload.Attributes.GetNamedItem("FilePath"); | 132 | var filePathNode = payload.Attributes.GetNamedItem("FilePath"); |
133 | XmlNode containerNode = payload.Attributes.GetNamedItem("Container"); | 133 | var containerNode = payload.Attributes.GetNamedItem("Container"); |
134 | 134 | ||
135 | string sourcePath = sourcePathNode.Value; | 135 | var sourcePath = sourcePathNode.Value; |
136 | string destinationPath = Path.Combine(containerNode.Value, filePathNode.Value); | 136 | var destinationPath = Path.Combine(containerNode.Value, filePathNode.Value); |
137 | 137 | ||
138 | this.attachedContainerPayloadNames.Add(new DictionaryEntry(sourcePath, destinationPath)); | 138 | this.attachedContainerPayloadNames.Add(new DictionaryEntry(sourcePath, destinationPath)); |
139 | } | 139 | } |
@@ -142,11 +142,6 @@ namespace WixToolset.Core.Burn.Bundles | |||
142 | return true; | 142 | return true; |
143 | } | 143 | } |
144 | 144 | ||
145 | internal void ExtractUXContainer(string uxExtractPath, object intermediateFolder) | ||
146 | { | ||
147 | throw new NotImplementedException(); | ||
148 | } | ||
149 | |||
150 | /// <summary> | 145 | /// <summary> |
151 | /// Gets each non-UX attached container from the exe and extracts its contents to the output directory. | 146 | /// Gets each non-UX attached container from the exe and extracts its contents to the output directory. |
152 | /// </summary> | 147 | /// </summary> |
@@ -167,11 +162,11 @@ namespace WixToolset.Core.Burn.Bundles | |||
167 | } | 162 | } |
168 | 163 | ||
169 | Directory.CreateDirectory(outputDirectory); | 164 | Directory.CreateDirectory(outputDirectory); |
170 | uint nextAddress = this.EngineSize; | 165 | var nextAddress = this.EngineSize; |
171 | for (int i = 1; i < this.AttachedContainers.Count; i++) | 166 | for (var i = 1; i < this.AttachedContainers.Count; i++) |
172 | { | 167 | { |
173 | ContainerSlot cntnr = this.AttachedContainers[i]; | 168 | var cntnr = this.AttachedContainers[i]; |
174 | string tempCabPath = Path.Combine(tempDirectory, $"a{i}.cab"); | 169 | var tempCabPath = Path.Combine(tempDirectory, $"a{i}.cab"); |
175 | 170 | ||
176 | this.binaryReader.BaseStream.Seek(nextAddress, SeekOrigin.Begin); | 171 | this.binaryReader.BaseStream.Seek(nextAddress, SeekOrigin.Begin); |
177 | using (Stream tempCab = File.Open(tempCabPath, FileMode.Create, FileAccess.Write)) | 172 | using (Stream tempCab = File.Open(tempCabPath, FileMode.Create, FileAccess.Write)) |
@@ -185,10 +180,10 @@ namespace WixToolset.Core.Burn.Bundles | |||
185 | nextAddress += cntnr.Size; | 180 | nextAddress += cntnr.Size; |
186 | } | 181 | } |
187 | 182 | ||
188 | foreach (DictionaryEntry entry in this.attachedContainerPayloadNames) | 183 | foreach (var entry in this.attachedContainerPayloadNames) |
189 | { | 184 | { |
190 | string sourcePath = Path.Combine(outputDirectory, (string)entry.Key); | 185 | var sourcePath = Path.Combine(outputDirectory, (string)entry.Key); |
191 | string destinationPath = Path.Combine(outputDirectory, (string)entry.Value); | 186 | var destinationPath = Path.Combine(outputDirectory, (string)entry.Value); |
192 | 187 | ||
193 | Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)); | 188 | Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)); |
194 | FileSystem.MoveFile(sourcePath, destinationPath); | 189 | FileSystem.MoveFile(sourcePath, destinationPath); |
diff --git a/src/wix/WixToolset.Core.Burn/BurnBackendWarnings.cs b/src/wix/WixToolset.Core.Burn/BurnBackendWarnings.cs index a0ffa1dc..033b755a 100644 --- a/src/wix/WixToolset.Core.Burn/BurnBackendWarnings.cs +++ b/src/wix/WixToolset.Core.Burn/BurnBackendWarnings.cs | |||
@@ -21,6 +21,11 @@ namespace WixToolset.Core.Burn | |||
21 | return Message(sourceLineNumbers, Ids.EmptyContainer, "The Container '{0}' is being ignored because it doesn't have any payloads.", containerId); | 21 | return Message(sourceLineNumbers, Ids.EmptyContainer, "The Container '{0}' is being ignored because it doesn't have any payloads.", containerId); |
22 | } | 22 | } |
23 | 23 | ||
24 | public static Message FailedToExtractAttachedContainers(SourceLineNumber sourceLineNumbers) | ||
25 | { | ||
26 | return Message(sourceLineNumbers, Ids.FailedToExtractAttachedContainers, "Failed to extract attached container. This most often happens when extracting a stripped bundle from the package cache, which is not supported."); | ||
27 | } | ||
28 | |||
24 | private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) | 29 | private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) |
25 | { | 30 | { |
26 | return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args); | 31 | return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args); |
@@ -31,6 +36,7 @@ namespace WixToolset.Core.Burn | |||
31 | AttachedContainerPayloadCollision = 8500, | 36 | AttachedContainerPayloadCollision = 8500, |
32 | AttachedContainerPayloadCollision2 = 8501, | 37 | AttachedContainerPayloadCollision2 = 8501, |
33 | EmptyContainer = 8502, | 38 | EmptyContainer = 8502, |
39 | FailedToExtractAttachedContainers = 8503, | ||
34 | } // last available is 8999. 9000 is VerboseMessages. | 40 | } // last available is 8999. 9000 is VerboseMessages. |
35 | } | 41 | } |
36 | } | 42 | } |
diff --git a/src/wix/WixToolset.Core.Burn/CommandLine/ExtractSubcommand.cs b/src/wix/WixToolset.Core.Burn/CommandLine/ExtractSubcommand.cs index 859f5e34..605ee045 100644 --- a/src/wix/WixToolset.Core.Burn/CommandLine/ExtractSubcommand.cs +++ b/src/wix/WixToolset.Core.Burn/CommandLine/ExtractSubcommand.cs | |||
@@ -52,7 +52,15 @@ namespace WixToolset.Core.Burn.CommandLine | |||
52 | using (var reader = BurnReader.Open(this.Messaging, this.InputPath)) | 52 | using (var reader = BurnReader.Open(this.Messaging, this.InputPath)) |
53 | { | 53 | { |
54 | reader.ExtractUXContainer(uxExtractPath, this.IntermediateFolder); | 54 | reader.ExtractUXContainer(uxExtractPath, this.IntermediateFolder); |
55 | reader.ExtractAttachedContainers(this.ExtractPath, this.IntermediateFolder); | 55 | |
56 | try | ||
57 | { | ||
58 | reader.ExtractAttachedContainers(this.ExtractPath, this.IntermediateFolder); | ||
59 | } | ||
60 | catch | ||
61 | { | ||
62 | this.Messaging.Write(BurnBackendWarnings.FailedToExtractAttachedContainers(new Data.SourceLineNumber(this.ExtractPath))); | ||
63 | } | ||
56 | } | 64 | } |
57 | 65 | ||
58 | return Task.FromResult(this.Messaging.LastErrorNumber); | 66 | return Task.FromResult(this.Messaging.LastErrorNumber); |