From add525424e44a050d3f98f64e56a85ab5d79955d Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 13 Feb 2020 14:28:58 -0500 Subject: Make BindResult disposable to manage WixOutput disposability. --- src/WixToolset.Core/CommandLine/BuildCommand.cs | 81 ++++++++++++++----------- 1 file changed, 44 insertions(+), 37 deletions(-) (limited to 'src/WixToolset.Core/CommandLine/BuildCommand.cs') 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 return; } - IBindResult bindResult; + IBindResult bindResult = null; + try { - var context = this.ServiceProvider.GetService(); - //context.CabbingThreadCount = this.CabbingThreadCount; - context.BurnStubPath = burnStubPath; - context.CabCachePath = cabCachePath; - context.Codepage = resolveResult.Codepage; - //context.DefaultCompressionLevel = this.DefaultCompressionLevel; - context.DelayedFields = resolveResult.DelayedFields; - context.ExpectedEmbeddedFiles = resolveResult.ExpectedEmbeddedFiles; - context.Extensions = this.ExtensionManager.GetServices(); - context.Ices = Array.Empty(); // TODO: set this correctly - context.IntermediateFolder = intermediateFolder; - context.IntermediateRepresentation = resolveResult.IntermediateRepresentation; - context.OutputPath = this.OutputFile; - context.OutputPdbPath = Path.ChangeExtension(this.OutputFile, ".wixpdb"); - context.SuppressIces = Array.Empty(); // TODO: set this correctly - context.SuppressValidation = true; // TODO: set this correctly - - var binder = this.ServiceProvider.GetService(); - bindResult = binder.Bind(context); - } + { + var context = this.ServiceProvider.GetService(); + //context.CabbingThreadCount = this.CabbingThreadCount; + context.BurnStubPath = burnStubPath; + context.CabCachePath = cabCachePath; + context.Codepage = resolveResult.Codepage; + //context.DefaultCompressionLevel = this.DefaultCompressionLevel; + context.DelayedFields = resolveResult.DelayedFields; + context.ExpectedEmbeddedFiles = resolveResult.ExpectedEmbeddedFiles; + context.Extensions = this.ExtensionManager.GetServices(); + context.Ices = Array.Empty(); // TODO: set this correctly + context.IntermediateFolder = intermediateFolder; + context.IntermediateRepresentation = resolveResult.IntermediateRepresentation; + context.OutputPath = this.OutputFile; + context.OutputPdbPath = Path.ChangeExtension(this.OutputFile, ".wixpdb"); + context.SuppressIces = Array.Empty(); // TODO: set this correctly + context.SuppressValidation = true; // TODO: set this correctly + + var binder = this.ServiceProvider.GetService(); + bindResult = binder.Bind(context); + } - if (this.Messaging.EncounteredError) - { - return; - } + if (this.Messaging.EncounteredError) + { + return; + } + { + var context = this.ServiceProvider.GetService(); + context.Extensions = this.ExtensionManager.GetServices(); + context.TrackedFiles = bindResult.TrackedFiles; + context.FileTransfers = bindResult.FileTransfers; + context.IntermediateFolder = intermediateFolder; + context.ContentsFile = this.ContentsFile; + context.OutputsFile = this.OutputsFile; + context.BuiltOutputsFile = this.BuiltOutputsFile; + context.SuppressAclReset = false; // TODO: correctly set SuppressAclReset + + var layout = this.ServiceProvider.GetService(); + layout.Layout(context); + } + } + finally { - var context = this.ServiceProvider.GetService(); - context.Extensions = this.ExtensionManager.GetServices(); - context.TrackedFiles = bindResult.TrackedFiles; - context.FileTransfers = bindResult.FileTransfers; - context.IntermediateFolder = intermediateFolder; - context.ContentsFile = this.ContentsFile; - context.OutputsFile = this.OutputsFile; - context.BuiltOutputsFile = this.BuiltOutputsFile; - context.SuppressAclReset = false; // TODO: correctly set SuppressAclReset - - var layout = this.ServiceProvider.GetService(); - layout.Layout(context); + bindResult?.Dispose(); } } -- cgit v1.2.3-55-g6feb