aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2020-05-30 14:53:05 -0700
committerRob Mensching <rob@firegiant.com>2020-05-30 15:07:21 -0700
commitd529525a1e331f3ef9ec2707791c99bd78fdd82f (patch)
tree1d9fe1f0c0ee9850371c916802eb03ec9dc37a87 /src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs
parent9c54d2fce80983bbee5f0f113b5aa30f22bc8a23 (diff)
downloadwix-d529525a1e331f3ef9ec2707791c99bd78fdd82f.tar.gz
wix-d529525a1e331f3ef9ec2707791c99bd78fdd82f.tar.bz2
wix-d529525a1e331f3ef9ec2707791c99bd78fdd82f.zip
Basic patching support
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs59
1 files changed, 43 insertions, 16 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs
index cd6170d0..bddcccb7 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs
@@ -12,6 +12,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
12 using WixToolset.Core.Native; 12 using WixToolset.Core.Native;
13 using WixToolset.Core.WindowsInstaller.Msi; 13 using WixToolset.Core.WindowsInstaller.Msi;
14 using WixToolset.Data; 14 using WixToolset.Data;
15 using WixToolset.Data.Tuples;
15 using WixToolset.Data.WindowsInstaller; 16 using WixToolset.Data.WindowsInstaller;
16 using WixToolset.Data.WindowsInstaller.Rows; 17 using WixToolset.Data.WindowsInstaller.Rows;
17 using WixToolset.Extensibility.Services; 18 using WixToolset.Extensibility.Services;
@@ -34,7 +35,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
34 35
35 public string OutputPath { private get; set; } 36 public string OutputPath { private get; set; }
36 37
37 public IEnumerable<string> SuppressedTableNames { private get; set; } 38 public TableDefinitionCollection TableDefinitions { private get; set; }
38 39
39 public string IntermediateFolder { private get; set; } 40 public string IntermediateFolder { private get; set; }
40 41
@@ -49,6 +50,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
49 return; 50 return;
50 } 51 }
51 52
53 var suppressedTableNames = this.AddBackSuppresedSequenceTables();
54
52 IMsmMerge2 merge = null; 55 IMsmMerge2 merge = null;
53 bool commit = true; 56 bool commit = true;
54 bool logOpen = false; 57 bool logOpen = false;
@@ -212,9 +215,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind
212 return; 215 return;
213 } 216 }
214 217
215 using (Database db = new Database(this.OutputPath, OpenDatabase.Direct)) 218 using (var db = new Database(this.OutputPath, OpenDatabase.Direct))
216 { 219 {
217 Table suppressActionTable = this.Output.Tables["WixSuppressAction"]; 220 var suppressActionTable = this.Output.Tables["WixSuppressAction"];
218 221
219 // suppress individual actions 222 // suppress individual actions
220 if (null != suppressActionTable) 223 if (null != suppressActionTable)
@@ -239,40 +242,38 @@ namespace WixToolset.Core.WindowsInstaller.Bind
239 } 242 }
240 243
241 // query for merge module actions in suppressed sequences and drop them 244 // query for merge module actions in suppressed sequences and drop them
242 foreach (string tableName in this.SuppressedTableNames) 245 foreach (var tableName in suppressedTableNames)
243 { 246 {
244 if (!db.TableExists(tableName)) 247 if (!db.TableExists(tableName))
245 { 248 {
246 continue; 249 continue;
247 } 250 }
248 251
249 using (View view = db.OpenExecuteView(String.Concat("SELECT `Action` FROM ", tableName))) 252 using (var view = db.OpenExecuteView(String.Concat("SELECT `Action` FROM ", tableName)))
250 { 253 {
251 foreach (Record resultRecord in view.Records) 254 foreach (var resultRecord in view.Records)
252 { 255 {
253 this.Messaging.Write(WarningMessages.SuppressMergedAction(resultRecord.GetString(1), tableName)); 256 this.Messaging.Write(WarningMessages.SuppressMergedAction(resultRecord.GetString(1), tableName));
254 } 257 }
255 } 258 }
256 259
257 // drop suppressed sequences 260 // drop suppressed sequences
258 using (View view = db.OpenExecuteView(String.Concat("DROP TABLE ", tableName))) 261 using (var view = db.OpenExecuteView(String.Concat("DROP TABLE ", tableName)))
259 { 262 {
260 } 263 }
261 264
262 // delete the validation rows 265 // delete the validation rows
263 using (View view = db.OpenView(String.Concat("DELETE FROM _Validation WHERE `Table` = ?"))) 266 using (var view = db.OpenView(String.Concat("DELETE FROM _Validation WHERE `Table` = ?")))
267 using (var record = new Record(1))
264 { 268 {
265 using (Record record = new Record(1)) 269 record.SetString(1, tableName);
266 { 270 view.Execute(record);
267 record.SetString(1, tableName);
268 view.Execute(record);
269 }
270 } 271 }
271 } 272 }
272 273
273 // now update the Attributes column for the files from the Merge Modules 274 // now update the Attributes column for the files from the Merge Modules
274 this.Messaging.Write(VerboseMessages.ResequencingMergeModuleFiles()); 275 this.Messaging.Write(VerboseMessages.ResequencingMergeModuleFiles());
275 using (View view = db.OpenView("SELECT `Sequence`, `Attributes` FROM `File` WHERE `File`=?")) 276 using (var view = db.OpenView("SELECT `Sequence`, `Attributes` FROM `File` WHERE `File`=?"))
276 { 277 {
277 foreach (var file in this.FileFacades) 278 foreach (var file in this.FileFacades)
278 { 279 {
@@ -281,13 +282,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind
281 continue; 282 continue;
282 } 283 }
283 284
284 using (Record record = new Record(1)) 285 using (var record = new Record(1))
285 { 286 {
286 record.SetString(1, file.Id); 287 record.SetString(1, file.Id);
287 view.Execute(record); 288 view.Execute(record);
288 } 289 }
289 290
290 using (Record recordUpdate = view.Fetch()) 291 using (var recordUpdate = view.Fetch())
291 { 292 {
292 if (null == recordUpdate) 293 if (null == recordUpdate)
293 { 294 {
@@ -332,5 +333,31 @@ namespace WixToolset.Core.WindowsInstaller.Bind
332 db.Commit(); 333 db.Commit();
333 } 334 }
334 } 335 }
336
337 private IEnumerable<string> AddBackSuppresedSequenceTables()
338 {
339 // Add back possibly suppressed sequence tables since all sequence tables must be present
340 // for the merge process to work. We'll drop the suppressed sequence tables again as
341 // necessary.
342 var suppressedTableNames = new HashSet<string>();
343
344 foreach (SequenceTable sequence in Enum.GetValues(typeof(SequenceTable)))
345 {
346 var sequenceTableName = (sequence == SequenceTable.AdvertiseExecuteSequence) ? "AdvtExecuteSequence" : sequence.ToString();
347 var sequenceTable = this.Output.Tables[sequenceTableName];
348
349 if (null == sequenceTable)
350 {
351 sequenceTable = this.Output.EnsureTable(this.TableDefinitions[sequenceTableName]);
352 }
353
354 if (0 == sequenceTable.Rows.Count)
355 {
356 suppressedTableNames.Add(sequenceTableName);
357 }
358 }
359
360 return suppressedTableNames;
361 }
335 } 362 }
336} 363}