diff options
| author | Bob Arnson <bob@firegiant.com> | 2020-02-13 14:28:58 -0500 |
|---|---|---|
| committer | Bob Arnson <bob@firegiant.com> | 2020-02-13 15:07:43 -0500 |
| commit | add525424e44a050d3f98f64e56a85ab5d79955d (patch) | |
| tree | ad02f4f8afe6dfb84db1fc10627058fc1ffe61fc /src/WixToolset.Core | |
| parent | 7116076d1af5af5f9da51a263a3b8b6a4a2e4ab8 (diff) | |
| download | wix-add525424e44a050d3f98f64e56a85ab5d79955d.tar.gz wix-add525424e44a050d3f98f64e56a85ab5d79955d.tar.bz2 wix-add525424e44a050d3f98f64e56a85ab5d79955d.zip | |
Make BindResult disposable to manage WixOutput disposability.
Diffstat (limited to 'src/WixToolset.Core')
| -rw-r--r-- | src/WixToolset.Core/BindResult.cs | 31 | ||||
| -rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 81 |
2 files changed, 75 insertions, 37 deletions
diff --git a/src/WixToolset.Core/BindResult.cs b/src/WixToolset.Core/BindResult.cs index c711b540..4edade7a 100644 --- a/src/WixToolset.Core/BindResult.cs +++ b/src/WixToolset.Core/BindResult.cs | |||
| @@ -2,16 +2,47 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Core | 3 | namespace WixToolset.Core |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 6 | using WixToolset.Data; | 7 | using WixToolset.Data; |
| 7 | using WixToolset.Extensibility.Data; | 8 | using WixToolset.Extensibility.Data; |
| 8 | 9 | ||
| 9 | internal class BindResult : IBindResult | 10 | internal class BindResult : IBindResult |
| 10 | { | 11 | { |
| 12 | private bool disposed; | ||
| 13 | |||
| 11 | public IEnumerable<IFileTransfer> FileTransfers { get; set; } | 14 | public IEnumerable<IFileTransfer> FileTransfers { get; set; } |
| 12 | 15 | ||
| 13 | public IEnumerable<ITrackedFile> TrackedFiles { get; set; } | 16 | public IEnumerable<ITrackedFile> TrackedFiles { get; set; } |
| 14 | 17 | ||
| 15 | public WixOutput Wixout { get; set; } | 18 | public WixOutput Wixout { get; set; } |
| 19 | |||
| 20 | #region IDisposable Support | ||
| 21 | /// <summary> | ||
| 22 | /// Disposes of the internal state of the file structure. | ||
| 23 | /// </summary> | ||
| 24 | public void Dispose() | ||
| 25 | { | ||
| 26 | this.Dispose(true); | ||
| 27 | GC.SuppressFinalize(this); | ||
| 28 | } | ||
| 29 | |||
| 30 | /// <summary> | ||
| 31 | /// Disposes of the internsl state of the file structure. | ||
| 32 | /// </summary> | ||
| 33 | /// <param name="disposing">True if disposing.</param> | ||
| 34 | protected virtual void Dispose(bool disposing) | ||
| 35 | { | ||
| 36 | if (!this.disposed) | ||
| 37 | { | ||
| 38 | if (disposing) | ||
| 39 | { | ||
| 40 | this.Wixout?.Dispose(); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | this.disposed = true; | ||
| 45 | } | ||
| 46 | #endregion | ||
| 16 | } | 47 | } |
| 17 | } | 48 | } |
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index 0868a3b6..a55fb55b 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
| @@ -294,47 +294,54 @@ namespace WixToolset.Core.CommandLine | |||
| 294 | return; | 294 | return; |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | IBindResult bindResult; | 297 | IBindResult bindResult = null; |
| 298 | try | ||
| 298 | { | 299 | { |
| 299 | var context = this.ServiceProvider.GetService<IBindContext>(); | 300 | { |
| 300 | //context.CabbingThreadCount = this.CabbingThreadCount; | 301 | var context = this.ServiceProvider.GetService<IBindContext>(); |
| 301 | context.BurnStubPath = burnStubPath; | 302 | //context.CabbingThreadCount = this.CabbingThreadCount; |
| 302 | context.CabCachePath = cabCachePath; | 303 | context.BurnStubPath = burnStubPath; |
| 303 | context.Codepage = resolveResult.Codepage; | 304 | context.CabCachePath = cabCachePath; |
| 304 | //context.DefaultCompressionLevel = this.DefaultCompressionLevel; | 305 | context.Codepage = resolveResult.Codepage; |
| 305 | context.DelayedFields = resolveResult.DelayedFields; | 306 | //context.DefaultCompressionLevel = this.DefaultCompressionLevel; |
| 306 | context.ExpectedEmbeddedFiles = resolveResult.ExpectedEmbeddedFiles; | 307 | context.DelayedFields = resolveResult.DelayedFields; |
| 307 | context.Extensions = this.ExtensionManager.GetServices<IBinderExtension>(); | 308 | context.ExpectedEmbeddedFiles = resolveResult.ExpectedEmbeddedFiles; |
| 308 | context.Ices = Array.Empty<string>(); // TODO: set this correctly | 309 | context.Extensions = this.ExtensionManager.GetServices<IBinderExtension>(); |
| 309 | context.IntermediateFolder = intermediateFolder; | 310 | context.Ices = Array.Empty<string>(); // TODO: set this correctly |
| 310 | context.IntermediateRepresentation = resolveResult.IntermediateRepresentation; | 311 | context.IntermediateFolder = intermediateFolder; |
| 311 | context.OutputPath = this.OutputFile; | 312 | context.IntermediateRepresentation = resolveResult.IntermediateRepresentation; |
| 312 | context.OutputPdbPath = Path.ChangeExtension(this.OutputFile, ".wixpdb"); | 313 | context.OutputPath = this.OutputFile; |
| 313 | context.SuppressIces = Array.Empty<string>(); // TODO: set this correctly | 314 | context.OutputPdbPath = Path.ChangeExtension(this.OutputFile, ".wixpdb"); |
| 314 | context.SuppressValidation = true; // TODO: set this correctly | 315 | context.SuppressIces = Array.Empty<string>(); // TODO: set this correctly |
| 315 | 316 | context.SuppressValidation = true; // TODO: set this correctly | |
| 316 | var binder = this.ServiceProvider.GetService<IBinder>(); | 317 | |
| 317 | bindResult = binder.Bind(context); | 318 | var binder = this.ServiceProvider.GetService<IBinder>(); |
| 318 | } | 319 | bindResult = binder.Bind(context); |
| 320 | } | ||
| 319 | 321 | ||
| 320 | if (this.Messaging.EncounteredError) | 322 | if (this.Messaging.EncounteredError) |
| 321 | { | 323 | { |
| 322 | return; | 324 | return; |
| 323 | } | 325 | } |
| 324 | 326 | ||
| 327 | { | ||
| 328 | var context = this.ServiceProvider.GetService<ILayoutContext>(); | ||
| 329 | context.Extensions = this.ExtensionManager.GetServices<ILayoutExtension>(); | ||
| 330 | context.TrackedFiles = bindResult.TrackedFiles; | ||
| 331 | context.FileTransfers = bindResult.FileTransfers; | ||
| 332 | context.IntermediateFolder = intermediateFolder; | ||
| 333 | context.ContentsFile = this.ContentsFile; | ||
| 334 | context.OutputsFile = this.OutputsFile; | ||
| 335 | context.BuiltOutputsFile = this.BuiltOutputsFile; | ||
| 336 | context.SuppressAclReset = false; // TODO: correctly set SuppressAclReset | ||
| 337 | |||
| 338 | var layout = this.ServiceProvider.GetService<ILayoutCreator>(); | ||
| 339 | layout.Layout(context); | ||
| 340 | } | ||
| 341 | } | ||
| 342 | finally | ||
| 325 | { | 343 | { |
| 326 | var context = this.ServiceProvider.GetService<ILayoutContext>(); | 344 | bindResult?.Dispose(); |
| 327 | context.Extensions = this.ExtensionManager.GetServices<ILayoutExtension>(); | ||
| 328 | context.TrackedFiles = bindResult.TrackedFiles; | ||
| 329 | context.FileTransfers = bindResult.FileTransfers; | ||
| 330 | context.IntermediateFolder = intermediateFolder; | ||
| 331 | context.ContentsFile = this.ContentsFile; | ||
| 332 | context.OutputsFile = this.OutputsFile; | ||
| 333 | context.BuiltOutputsFile = this.BuiltOutputsFile; | ||
| 334 | context.SuppressAclReset = false; // TODO: correctly set SuppressAclReset | ||
| 335 | |||
| 336 | var layout = this.ServiceProvider.GetService<ILayoutCreator>(); | ||
| 337 | layout.Layout(context); | ||
| 338 | } | 345 | } |
| 339 | } | 346 | } |
| 340 | 347 | ||
