aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs66
-rw-r--r--src/WixToolset.Core.WindowsInstaller/MsiBackend.cs22
-rw-r--r--src/WixToolset.Core.WindowsInstaller/MsmBackend.cs31
3 files changed, 75 insertions, 44 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
index 411f64bf..3e4806a7 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
@@ -17,11 +17,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind
17 /// <summary> 17 /// <summary>
18 /// Binds a databse. 18 /// Binds a databse.
19 /// </summary> 19 /// </summary>
20 internal class BindDatabaseCommand 20 internal class BindDatabaseCommand : IDisposable
21 { 21 {
22 // As outlined in RFC 4122, this is our namespace for generating name-based (version 3) UUIDs. 22 // As outlined in RFC 4122, this is our namespace for generating name-based (version 3) UUIDs.
23 internal static readonly Guid WixComponentGuidNamespace = new Guid("{3064E5C6-FB63-4FE9-AC49-E446A792EFA5}"); 23 internal static readonly Guid WixComponentGuidNamespace = new Guid("{3064E5C6-FB63-4FE9-AC49-E446A792EFA5}");
24 24
25 private bool disposed;
26
25 public BindDatabaseCommand(IBindContext context, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtension, Validator validator) 27 public BindDatabaseCommand(IBindContext context, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtension, Validator validator)
26 { 28 {
27 this.ServiceProvider = context.ServiceProvider; 29 this.ServiceProvider = context.ServiceProvider;
@@ -92,7 +94,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
92 94
93 public IEnumerable<ITrackedFile> TrackedFiles { get; private set; } 95 public IEnumerable<ITrackedFile> TrackedFiles { get; private set; }
94 96
95 public Pdb Pdb { get; private set; } 97 public WixOutput Wixout { get; private set; }
96 98
97 public void Execute() 99 public void Execute()
98 { 100 {
@@ -524,29 +526,41 @@ namespace WixToolset.Core.WindowsInstaller.Bind
524 trackedFiles.AddRange(command.TrackedFiles); 526 trackedFiles.AddRange(command.TrackedFiles);
525 } 527 }
526 528
527 this.Pdb = new Pdb { Output = output }; 529 this.Wixout = this.CreateWixout(trackedFiles, this.Intermediate, output);
528
529 if (!String.IsNullOrEmpty(this.OutputPdbPath))
530 {
531 var trackPdb = this.BackendHelper.TrackFile(this.OutputPdbPath, TrackedFileType.Final);
532 trackedFiles.Add(trackPdb);
533
534 this.Pdb.Save(trackPdb.Path);
535 }
536 530
537 this.FileTransfers = fileTransfers; 531 this.FileTransfers = fileTransfers;
538 // TODO: this is not sufficient to collect all Input files (for example, it misses Binary and Icon tables). 532 // TODO: this is not sufficient to collect all Input files (for example, it misses Binary and Icon tables).
539 trackedFiles.AddRange(fileFacades.Select(f => this.BackendHelper.TrackFile(f.File.Source.Path, TrackedFileType.Input, f.File.SourceLineNumbers))); 533 trackedFiles.AddRange(fileFacades.Select(f => this.BackendHelper.TrackFile(f.File.Source.Path, TrackedFileType.Input, f.File.SourceLineNumbers)));
540 this.TrackedFiles = trackedFiles; 534 this.TrackedFiles = trackedFiles;
541 535
542 // TODO: Eventually this gets removed 536 // TODO: Eventually this gets removed
543 var intermediate = new Intermediate(this.Intermediate.Id, new[] { section }, this.Intermediate.Localizations.ToDictionary(l => l.Culture, StringComparer.OrdinalIgnoreCase), this.Intermediate.EmbedFilePaths); 537 var intermediate = new Intermediate(this.Intermediate.Id, new[] { section }, this.Intermediate.Localizations.ToDictionary(l => l.Culture, StringComparer.OrdinalIgnoreCase));
544 var trackIntermediate = this.BackendHelper.TrackFile(Path.Combine(this.IntermediateFolder, Path.GetFileName(Path.ChangeExtension(this.OutputPath, "wir"))), TrackedFileType.Intermediate); 538 var trackIntermediate = this.BackendHelper.TrackFile(Path.Combine(this.IntermediateFolder, Path.GetFileName(Path.ChangeExtension(this.OutputPath, "wir"))), TrackedFileType.Intermediate);
545 intermediate.Save(trackIntermediate.Path); 539 intermediate.Save(trackIntermediate.Path);
546 trackedFiles.Add(trackIntermediate); 540 trackedFiles.Add(trackIntermediate);
541 }
547 542
548 //transfer = this.BackendHelper.CreateFileTransfer(intermediatePath, Path.ChangeExtension(this.OutputPath, "wir"), true, FileTransferType.Built); 543 private WixOutput CreateWixout(List<ITrackedFile> trackedFiles, Intermediate intermediate, Output output)
549 //fileTransfers.Add(transfer); 544 {
545 WixOutput wixout;
546
547 if (String.IsNullOrEmpty(this.OutputPdbPath))
548 {
549 wixout = WixOutput.Create();
550 }
551 else
552 {
553 var trackPdb = this.BackendHelper.TrackFile(this.OutputPdbPath, TrackedFileType.Final);
554 trackedFiles.Add(trackPdb);
555
556 wixout = WixOutput.Create(trackPdb.Path);
557 }
558
559 intermediate.Save(wixout);
560
561 output.Save(wixout);
562
563 return wixout;
550 } 564 }
551 565
552#if TODO_FINISH_PATCH 566#if TODO_FINISH_PATCH
@@ -934,5 +948,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind
934 948
935 return command.GeneratedTemporaryFiles; 949 return command.GeneratedTemporaryFiles;
936 } 950 }
951
952 #region IDisposable Support
953
954 public void Dispose()
955 {
956 this.Dispose(true);
957 }
958
959 protected virtual void Dispose(bool disposing)
960 {
961 if (!this.disposed)
962 {
963 if (disposing)
964 {
965 this.Wixout?.Dispose();
966 }
967
968 this.disposed = true;
969 }
970 }
971
972 #endregion
937 } 973 }
938} 974}
diff --git a/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs b/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs
index 2ebb3f13..5cd7204a 100644
--- a/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs
+++ b/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs
@@ -2,7 +2,6 @@
2 2
3namespace WixToolset.Core.WindowsInstaller 3namespace WixToolset.Core.WindowsInstaller
4{ 4{
5 using System;
6 using WixToolset.Core.WindowsInstaller.Bind; 5 using WixToolset.Core.WindowsInstaller.Bind;
7 using WixToolset.Core.WindowsInstaller.Inscribe; 6 using WixToolset.Core.WindowsInstaller.Inscribe;
8 using WixToolset.Core.WindowsInstaller.Unbind; 7 using WixToolset.Core.WindowsInstaller.Unbind;
@@ -26,18 +25,21 @@ namespace WixToolset.Core.WindowsInstaller
26 25
27 var validator = Validator.CreateFromContext(context, "darice.cub"); 26 var validator = Validator.CreateFromContext(context, "darice.cub");
28 27
29 var command = new BindDatabaseCommand(context, backendExtensions, validator); 28 using (var command = new BindDatabaseCommand(context, backendExtensions, validator))
30 command.Execute(); 29 {
30 command.Execute();
31 31
32 var result = context.ServiceProvider.GetService<IBindResult>(); 32 var result = context.ServiceProvider.GetService<IBindResult>();
33 result.FileTransfers = command.FileTransfers; 33 result.FileTransfers = command.FileTransfers;
34 result.TrackedFiles = command.TrackedFiles; 34 result.TrackedFiles = command.TrackedFiles;
35 35
36 foreach (var extension in backendExtensions) 36 foreach (var extension in backendExtensions)
37 { 37 {
38 extension.PostBackendBind(result, command.Pdb); 38 extension.PostBackendBind(result, command.Wixout);
39 }
40
41 return result;
39 } 42 }
40 return result;
41 } 43 }
42 44
43 public IDecompileResult Decompile(IDecompileContext context) 45 public IDecompileResult Decompile(IDecompileContext context)
diff --git a/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs b/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs
index d5281759..f048b4e2 100644
--- a/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs
+++ b/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs
@@ -2,7 +2,6 @@
2 2
3namespace WixToolset.Core.WindowsInstaller 3namespace WixToolset.Core.WindowsInstaller
4{ 4{
5 using System;
6 using WixToolset.Core.WindowsInstaller.Bind; 5 using WixToolset.Core.WindowsInstaller.Bind;
7 using WixToolset.Core.WindowsInstaller.Unbind; 6 using WixToolset.Core.WindowsInstaller.Unbind;
8 using WixToolset.Data; 7 using WixToolset.Data;
@@ -25,24 +24,21 @@ namespace WixToolset.Core.WindowsInstaller
25 24
26 var validator = Validator.CreateFromContext(context, "mergemod.cub"); 25 var validator = Validator.CreateFromContext(context, "mergemod.cub");
27 26
28 var command = new BindDatabaseCommand(context, backendExtensions, validator); 27 using (var command = new BindDatabaseCommand(context, backendExtensions, validator))
29 command.Execute(); 28 {
29 command.Execute();
30 30
31 var result = context.ServiceProvider.GetService<IBindResult>(); 31 var result = context.ServiceProvider.GetService<IBindResult>();
32 result.FileTransfers = command.FileTransfers; 32 result.FileTransfers = command.FileTransfers;
33 result.TrackedFiles = command.TrackedFiles; 33 result.TrackedFiles = command.TrackedFiles;
34 34
35 foreach (var extension in backendExtensions) 35 foreach (var extension in backendExtensions)
36 { 36 {
37 extension.PostBackendBind(result, command.Pdb); 37 extension.PostBackendBind(result, command.Wixout);
38 } 38 }
39 39
40 if (!String.IsNullOrEmpty(context.OutputPdbPath)) 40 return result;
41 {
42 command.Pdb?.Save(context.OutputPdbPath);
43 } 41 }
44
45 return result;
46 } 42 }
47 43
48 public IDecompileResult Decompile(IDecompileContext context) 44 public IDecompileResult Decompile(IDecompileContext context)
@@ -67,10 +63,7 @@ namespace WixToolset.Core.WindowsInstaller
67 return result; 63 return result;
68 } 64 }
69 65
70 public bool Inscribe(IInscribeContext context) 66 public bool Inscribe(IInscribeContext context) => false;
71 {
72 return false;
73 }
74 67
75 public Intermediate Unbind(IUnbindContext context) 68 public Intermediate Unbind(IUnbindContext context)
76 { 69 {