aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-03-26 12:59:03 -0700
committerRob Mensching <rob@firegiant.com>2021-04-02 14:58:00 -0700
commit9cca339473d77c7036035f949239f5231c325968 (patch)
tree342399ad52d1eb8102be17c71a12242c566fca25 /src/WixToolset.Core.WindowsInstaller
parent67bcf306aa020c5480b6dd28eab5db3d49264585 (diff)
downloadwix-9cca339473d77c7036035f949239f5231c325968.tar.gz
wix-9cca339473d77c7036035f949239f5231c325968.tar.bz2
wix-9cca339473d77c7036035f949239f5231c325968.zip
Integrate the IntermediateSection and IntermediateSymbol mutable changes
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs32
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs27
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs17
3 files changed, 28 insertions, 48 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
index d7faa382..cfa84629 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
@@ -86,25 +86,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind
86 86
87 this.UncompressedFileFacades = Array.Empty<IFileFacade>(); 87 this.UncompressedFileFacades = Array.Empty<IFileFacade>();
88 } 88 }
89 else if (mediaTemplateSymbols.Count == 0)
90 {
91 var filesByCabinetMedia = new Dictionary<MediaSymbol, List<IFileFacade>>();
92
93 var uncompressedFiles = new List<IFileFacade>();
94
95 this.ManuallyAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles);
96
97 this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<IFileFacade>)kvp.Value);
98
99 this.UncompressedFileFacades = uncompressedFiles;
100 }
101 else 89 else
102 { 90 {
103 var filesByCabinetMedia = new Dictionary<MediaSymbol, List<IFileFacade>>(); 91 var filesByCabinetMedia = new Dictionary<MediaSymbol, List<IFileFacade>>();
104
105 var uncompressedFiles = new List<IFileFacade>(); 92 var uncompressedFiles = new List<IFileFacade>();
106 93
107 this.AutoAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles); 94 if (mediaTemplateSymbols.Count > 0)
95 {
96 this.AutoAssignFiles(mediaTemplateSymbols, mediaSymbols, filesByCabinetMedia, uncompressedFiles);
97 }
98 else
99 {
100 this.ManuallyAssignFiles(mediaSymbols, filesByCabinetMedia, uncompressedFiles);
101 }
108 102
109 this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<IFileFacade>)kvp.Value); 103 this.FileFacadesByCabinetMedia = filesByCabinetMedia.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<IFileFacade>)kvp.Value);
110 104
@@ -115,7 +109,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
115 /// <summary> 109 /// <summary>
116 /// Assign files to cabinets based on MediaTemplate authoring. 110 /// Assign files to cabinets based on MediaTemplate authoring.
117 /// </summary> 111 /// </summary>
118 private void AutoAssignFiles(List<MediaSymbol> mediaTable, Dictionary<MediaSymbol, List<IFileFacade>> filesByCabinetMedia, List<IFileFacade> uncompressedFiles) 112 private void AutoAssignFiles(List<WixMediaTemplateSymbol> mediaTemplateTable, List<MediaSymbol> mediaSymbols, Dictionary<MediaSymbol, List<IFileFacade>> filesByCabinetMedia, List<IFileFacade> uncompressedFiles)
119 { 113 {
120 const int MaxCabIndex = 999; 114 const int MaxCabIndex = 999;
121 115
@@ -126,13 +120,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
126 120
127 MediaSymbol currentMediaRow = null; 121 MediaSymbol currentMediaRow = null;
128 122
129 var mediaTemplateTable = this.Section.Symbols.OfType<WixMediaTemplateSymbol>();
130
131 // Remove all previous media symbols since they will be replaced with 123 // Remove all previous media symbols since they will be replaced with
132 // media template. 124 // media template.
133 foreach (var mediaSymbol in mediaTable) 125 foreach (var mediaSymbol in mediaSymbols)
134 { 126 {
135 this.Section.Symbols.Remove(mediaSymbol); 127 this.Section.RemoveSymbol(mediaSymbol);
136 } 128 }
137 129
138 // Auto assign files to cabinets based on maximum uncompressed media size 130 // Auto assign files to cabinets based on maximum uncompressed media size
@@ -218,7 +210,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
218 } 210 }
219 211
220 // If there are uncompressed files and no MediaRow, create a default one. 212 // If there are uncompressed files and no MediaRow, create a default one.
221 if (uncompressedFiles.Count > 0 && !this.Section.Symbols.OfType<MediaSymbol>().Any()) 213 if (uncompressedFiles.Count > 0 && mediaSymbolsByDiskId.Count == 0)
222 { 214 {
223 var defaultMediaRow = this.Section.AddSymbol(new MediaSymbol(null, new Identifier(AccessModifier.Section, 1)) 215 var defaultMediaRow = this.Section.AddSymbol(new MediaSymbol(null, new Identifier(AccessModifier.Section, 1))
224 { 216 {
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs
index 6d802d98..5f8df92c 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs
@@ -241,23 +241,20 @@ namespace WixToolset.Core.WindowsInstaller.Bind
241 241
242 foreach (var section in this.Intermediate.Sections) 242 foreach (var section in this.Intermediate.Sections)
243 { 243 {
244 for (var i = section.Symbols.Count - 1; i >= 0; i--) 244 // Remove all summary information from the symbols and remember those that
245 // are not calculated or reserved.
246 foreach (var patchSummaryInfo in section.Symbols.OfType<SummaryInformationSymbol>().ToList())
245 { 247 {
246 if (section.Symbols[i] is SummaryInformationSymbol patchSummaryInfo) 248 section.RemoveSymbol(patchSummaryInfo);
249
250 if (patchSummaryInfo.PropertyId != SummaryInformationType.PatchProductCodes &&
251 patchSummaryInfo.PropertyId != SummaryInformationType.PatchCode &&
252 patchSummaryInfo.PropertyId != SummaryInformationType.PatchInstallerRequirement &&
253 patchSummaryInfo.PropertyId != SummaryInformationType.Reserved11 &&
254 patchSummaryInfo.PropertyId != SummaryInformationType.Reserved14 &&
255 patchSummaryInfo.PropertyId != SummaryInformationType.Reserved16)
247 { 256 {
248 // Remove all summary information from the symbols and remember those that 257 result.Add(patchSummaryInfo.PropertyId, patchSummaryInfo);
249 // are not calculated or reserved.
250 section.Symbols.RemoveAt(i);
251
252 if (patchSummaryInfo.PropertyId != SummaryInformationType.PatchProductCodes &&
253 patchSummaryInfo.PropertyId != SummaryInformationType.PatchCode &&
254 patchSummaryInfo.PropertyId != SummaryInformationType.PatchInstallerRequirement &&
255 patchSummaryInfo.PropertyId != SummaryInformationType.Reserved11 &&
256 patchSummaryInfo.PropertyId != SummaryInformationType.Reserved14 &&
257 patchSummaryInfo.PropertyId != SummaryInformationType.Reserved16)
258 {
259 result.Add(patchSummaryInfo.PropertyId, patchSummaryInfo);
260 }
261 } 258 }
262 } 259 }
263 } 260 }
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
index 5e72ec5c..94fa0a6a 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
@@ -173,21 +173,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
173 } 173 }
174 174
175 // Remove all existing WixActionSymbols from the section then add the 175 // Remove all existing WixActionSymbols from the section then add the
176 // scheduled actions back to the section. Note: we add the indices in 176 // scheduled actions back to the section.
177 // reverse order to make it easy to remove them from the list later. 177 var removeActionSymbols = this.Section.Symbols.Where(s => s.Definition.Type == SymbolDefinitionType.WixAction).ToList();
178 var removeIndices = new List<int>();
179 for (var i = this.Section.Symbols.Count - 1; i >= 0; --i)
180 {
181 var symbol = this.Section.Symbols[i];
182 if (symbol.Definition.Type == SymbolDefinitionType.WixAction)
183 {
184 removeIndices.Add(i);
185 }
186 }
187 178
188 foreach (var removeIndex in removeIndices) 179 foreach (var removeSymbol in removeActionSymbols)
189 { 180 {
190 this.Section.Symbols.RemoveAt(removeIndex); 181 this.Section.RemoveSymbol(removeSymbol);
191 } 182 }
192 183
193 foreach (var action in scheduledActionSymbols) 184 foreach (var action in scheduledActionSymbols)