From 155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 19 Dec 2017 12:25:40 -0800 Subject: Integrate simplified message handling --- .../Bind/AssignMediaCommand.cs | 21 ++++++---- .../Bind/BindDatabaseCommand.cs | 49 ++++++++++++---------- .../Bind/BindTransformCommand.cs | 15 ++++--- .../Bind/CabinetBuilder.cs | 22 +++++----- .../Bind/CabinetResolver.cs | 2 +- .../Bind/CalculateComponentGuids.cs | 16 ++++--- .../Bind/CopyTransformDataCommand.cs | 11 +++-- .../Bind/CreateCabinetsCommand.cs | 41 +++++++++--------- .../Bind/CreateIdtFileCommand.cs | 10 +++-- .../Bind/ExtractMergeModuleFilesCommand.cs | 26 +++++++----- .../Bind/GenerateDatabaseCommand.cs | 18 ++++---- .../Bind/MergeModulesCommand.cs | 37 ++++++++-------- .../Bind/ProcessUncompressedFilesCommand.cs | 2 +- .../Bind/SequenceActionsCommand.cs | 43 +++++++++---------- .../Bind/UpdateControlTextCommand.cs | 11 +++-- .../Bind/UpdateFileFacadesCommand.cs | 46 ++++++++++---------- 16 files changed, 208 insertions(+), 162 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Bind') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs index 1f2cee74..0f278640 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs @@ -8,22 +8,25 @@ namespace WixToolset.Core.WindowsInstaller.Bind using System.Linq; using WixToolset.Core.Bind; using WixToolset.Data; - using WixToolset.Data.Rows; using WixToolset.Data.Tuples; + using WixToolset.Extensibility.Services; /// /// AssignMediaCommand assigns files to cabs based on Media or MediaTemplate rows. /// internal class AssignMediaCommand { - public AssignMediaCommand(IntermediateSection section) + public AssignMediaCommand(IntermediateSection section, IMessaging messaging) { this.CabinetNameTemplate = "Cab{0}.cab"; this.Section = section; + this.Messaging = messaging; } private IntermediateSection Section { get; } + private IMessaging Messaging { get; } + public IEnumerable FileFacades { private get; set; } public bool FilesCompressed { private get; set; } @@ -60,7 +63,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // If both tables are authored, it is an error. if (mediaTemplateTable.Count > 0 && mediaTable.Count > 1) { - throw new WixException(WixErrors.MediaTableCollision(null)); + throw new WixException(ErrorMessages.MediaTableCollision(null)); } // When building merge module, all the files go to "#MergeModule.CABinet". @@ -144,11 +147,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (FormatException) { - throw new WixException(WixErrors.IllegalEnvironmentVariable("WIX_MUMS", mumsString)); + throw new WixException(ErrorMessages.IllegalEnvironmentVariable("WIX_MUMS", mumsString)); } catch (OverflowException) { - throw new WixException(WixErrors.MaximumUncompressedMediaSizeTooLarge(null, maxPreCabSizeInMB)); + throw new WixException(ErrorMessages.MaximumUncompressedMediaSizeTooLarge(null, maxPreCabSizeInMB)); } foreach (FileFacade facade in this.FileFacades) @@ -234,8 +237,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (cabinetMediaRows.TryGetValue(mediaRow.Cabinet, out var existingRow)) { - Messaging.Instance.OnMessage(WixErrors.DuplicateCabinetName(mediaRow.SourceLineNumbers, mediaRow.Cabinet)); - Messaging.Instance.OnMessage(WixErrors.DuplicateCabinetName2(existingRow.SourceLineNumbers, existingRow.Cabinet)); + this.Messaging.Write(ErrorMessages.DuplicateCabinetName(mediaRow.SourceLineNumbers, mediaRow.Cabinet)); + this.Messaging.Write(ErrorMessages.DuplicateCabinetName2(existingRow.SourceLineNumbers, existingRow.Cabinet)); } else { @@ -259,7 +262,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (!mediaRows.TryGetValue(facade.WixFile.DiskId, out var mediaRow)) { - Messaging.Instance.OnMessage(WixErrors.MissingMedia(facade.File.SourceLineNumbers, facade.WixFile.DiskId)); + this.Messaging.Write(ErrorMessages.MissingMedia(facade.File.SourceLineNumbers, facade.WixFile.DiskId)); continue; } @@ -279,7 +282,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - Messaging.Instance.OnMessage(WixErrors.ExpectedMediaCabinet(facade.File.SourceLineNumbers, facade.File.File, facade.WixFile.DiskId)); + this.Messaging.Write(ErrorMessages.ExpectedMediaCabinet(facade.File.SourceLineNumbers, facade.File.File, facade.WixFile.DiskId)); } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 9e30aed2..410e462a 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -35,6 +35,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.ExpectedEmbeddedFiles = context.ExpectedEmbeddedFiles; this.Extensions = context.Extensions; this.Intermediate = context.IntermediateRepresentation; + this.Messaging = context.Messaging; this.OutputPath = context.OutputPath; this.PdbFile = context.OutputPdbPath; this.IntermediateFolder = context.IntermediateFolder; @@ -68,6 +69,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind private Intermediate Intermediate { get; } + private IMessaging Messaging { get; } + private string OutputPath { get; } private bool SuppressAddingValidationRows { get; } @@ -160,7 +163,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Sequence all the actions. { var command = new SequenceActionsCommand(section); - command.Messaging = Messaging.Instance; + command.Messaging = this.Messaging; command.Execute(); } @@ -191,12 +194,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind ////} #endif - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } - Messaging.Instance.OnMessage(WixVerboses.UpdatingFileInformation()); + this.Messaging.Write(VerboseMessages.UpdatingFileInformation()); // This must occur after all variables and source paths have been resolved. List fileFacades; @@ -215,7 +218,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Gather information about files that did not come from merge modules (i.e. rows with a reference to the File table). { - var command = new UpdateFileFacadesCommand(section); + var command = new UpdateFileFacadesCommand(this.Messaging, section); command.FileFacades = fileFacades; command.UpdateFileFacades = fileFacades.Where(f => !f.FromModule); command.OverwriteHash = true; @@ -227,13 +230,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Now that the variable cache is populated, resolve any delayed fields. if (this.DelayedFields.Any()) { - var command = new ResolveDelayedFieldsCommand(this.DelayedFields, variableCache); + var command = new ResolveDelayedFieldsCommand(this.Messaging, this.DelayedFields, variableCache); command.Execute(); } // Set generated component guids. { - var command = new CalculateComponentGuids(section); + var command = new CalculateComponentGuids(this.Messaging, section); command.Execute(); } @@ -244,7 +247,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (wixMergeTuples.Any()) { - var command = new ExtractMergeModuleFilesCommand(section, wixMergeTuples); + var command = new ExtractMergeModuleFilesCommand(this.Messaging, section, wixMergeTuples); command.FileFacades = fileFacades; command.OutputInstallerVersion = installerVersion; command.SuppressLayout = this.SuppressLayout; @@ -265,7 +268,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind #endif // stop processing if an error previously occurred - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } @@ -280,7 +283,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind Dictionary> filesByCabinetMedia; IEnumerable uncompressedFiles; { - var command = new AssignMediaCommand(section); + var command = new AssignMediaCommand(section, this.Messaging); command.FileFacades = fileFacades; command.FilesCompressed = compressed; command.Execute(); @@ -291,7 +294,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // stop processing if an error previously occurred - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } @@ -355,7 +358,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind #endif // Stop processing if an error previously occurred. - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } @@ -374,13 +377,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind string layoutDirectory = Path.GetDirectoryName(this.OutputPath); if (!this.SuppressLayout || OutputType.Module == output.Type) { - Messaging.Instance.OnMessage(WixVerboses.CreatingCabinetFiles()); + this.Messaging.Write(VerboseMessages.CreatingCabinetFiles()); var command = new CreateCabinetsCommand(); command.CabbingThreadCount = this.CabbingThreadCount; command.CabCachePath = this.CabCachePath; command.DefaultCompressionLevel = this.DefaultCompressionLevel; command.Output = output; + command.Messaging = this.Messaging; command.BackendExtensions = this.BackendExtensions; command.LayoutDirectory = layoutDirectory; command.Compressed = compressed; @@ -435,13 +439,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.ValidateComponentGuids(output); // stop processing if an error previously occurred - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } // Generate database file. - Messaging.Instance.OnMessage(WixVerboses.GeneratingDatabase()); + this.Messaging.Write(VerboseMessages.GeneratingDatabase()); string tempDatabaseFile = Path.Combine(this.IntermediateFolder, Path.GetFileName(this.OutputPath)); this.GenerateDatabase(output, tempDatabaseFile, false, false); @@ -452,7 +456,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // Stop processing if an error previously occurred. - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } @@ -468,7 +472,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Merge modules. if (OutputType.Product == output.Type) { - Messaging.Instance.OnMessage(WixVerboses.MergingModules()); + this.Messaging.Write(VerboseMessages.MergingModules()); var command = new MergeModulesCommand(); command.FileFacades = fileFacades; @@ -478,7 +482,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.Execute(); } - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } @@ -492,12 +496,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind // set the output file for source line information this.Validator.Output = this.Output; - Messaging.Instance.OnMessage(WixVerboses.ValidatingDatabase()); + Messaging.Instance.Write(WixVerboses.ValidatingDatabase()); this.Validator.Validate(tempDatabaseFile); stopwatch.Stop(); - Messaging.Instance.OnMessage(WixVerboses.ValidatedDatabase(stopwatch.ElapsedMilliseconds)); + Messaging.Instance.Write(WixVerboses.ValidatedDatabase(stopwatch.ElapsedMilliseconds)); // Stop processing if an error occurred. if (Messaging.Instance.EncounteredError) @@ -508,7 +512,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind #endif // Process uncompressed files. - if (!Messaging.Instance.EncounteredError && !this.SuppressLayout && uncompressedFiles.Any()) + if (!this.Messaging.EncounteredError && !this.SuppressLayout && uncompressedFiles.Any()) { var command = new ProcessUncompressedFilesCommand(section); command.Compressed = compressed; @@ -908,11 +912,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (allComponentsHaveConditions) { - Messaging.Instance.OnMessage(WixWarnings.DuplicateComponentGuidsMustHaveMutuallyExclusiveConditions(row.SourceLineNumbers, row.Component, row.Guid)); + this.Messaging.Write(WarningMessages.DuplicateComponentGuidsMustHaveMutuallyExclusiveConditions(row.SourceLineNumbers, row.Component, row.Guid)); } else { - Messaging.Instance.OnMessage(WixErrors.DuplicateComponentGuids(row.SourceLineNumbers, row.Component, row.Guid)); + this.Messaging.Write(ErrorMessages.DuplicateComponentGuids(row.SourceLineNumbers, row.Component, row.Guid)); } } @@ -929,6 +933,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind private void UpdateControlText(Output output) { var command = new UpdateControlTextCommand(); + command.Messaging = this.Messaging; command.BBControlTable = output.Tables["BBControl"]; command.WixBBControlTable = output.Tables["WixBBControl"]; command.ControlTable = output.Tables["Control"]; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs index 49440cea..800ebac0 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs @@ -6,11 +6,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind using System.Collections.Generic; using System.Globalization; using System.IO; + using WixToolset.Core.Native; using WixToolset.Data; + using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; using WixToolset.Msi; - using WixToolset.Core.Native; - using WixToolset.Data.WindowsInstaller; internal class BindTransformCommand { @@ -22,6 +23,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind public Output Transform { private get; set; } + public IMessaging Messaging { private get; set; } + public string OutputPath { private get; set; } public void Execute() @@ -197,7 +200,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (((int)TransformFlags.ValidateUpgradeCode & transformFlags) != 0 && (String.IsNullOrEmpty(targetUpgradeCode) || String.IsNullOrEmpty(updatedUpgradeCode))) { - Messaging.Instance.OnMessage(WixErrors.BothUpgradeCodesRequired()); + this.Messaging.Write(ErrorMessages.BothUpgradeCodesRequired()); } string emptyFile = null; @@ -276,7 +279,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (RowOperation.Add == fileRow.Operation) { - Messaging.Instance.OnMessage(WixErrors.InvalidAddedFileRowWithoutSequence(fileRow.SourceLineNumbers, (string)fileRow[0])); + this.Messaging.Write(ErrorMessages.InvalidAddedFileRowWithoutSequence(fileRow.SourceLineNumbers, (string)fileRow[0])); break; } @@ -384,7 +387,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind //} // Any errors encountered up to this point can cause errors during generation. - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } @@ -419,7 +422,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - Messaging.Instance.OnMessage(WixErrors.NoDifferencesInTransform(this.Transform.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.NoDifferencesInTransform(this.Transform.SourceLineNumbers)); } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs index fde781a3..0c167699 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs @@ -4,13 +4,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind { using System; using System.Collections; - using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using WixToolset.Core.Bind; using WixToolset.Core.Native; using WixToolset.Data; + using WixToolset.Extensibility.Services; /// /// Builds cabinets using multiple threads. This implements a thread pool that generates cabinets with multiple @@ -25,16 +25,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Address of Binder's callback function for Cabinet Splitting private IntPtr newCabNamesCallBackAddress; - public int MaximumCabinetSizeForLargeFileSplitting { get; set; } - - public int MaximumUncompressedMediaSize { get; set; } - /// /// Instantiate a new CabinetBuilder. /// /// number of threads to use /// Address of Binder's callback function for Cabinet Splitting - public CabinetBuilder(int threadCount, IntPtr newCabNamesCallBackAddress) + public CabinetBuilder(IMessaging messaging, int threadCount, IntPtr newCabNamesCallBackAddress) { if (0 >= threadCount) { @@ -43,13 +39,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.cabinetWorkItems = new Queue(); this.lockObject = new object(); - + this.Messaging = messaging; this.threadCount = threadCount; // Set Address of Binder's callback function for Cabinet Splitting this.newCabNamesCallBackAddress = newCabNamesCallBackAddress; } + private IMessaging Messaging { get; } + + public int MaximumCabinetSizeForLargeFileSplitting { get; set; } + + public int MaximumUncompressedMediaSize { get; set; } + /// /// Enqueues a CabinetWorkItem to the queue. /// @@ -119,11 +121,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (WixException we) { - Messaging.Instance.OnMessage(we.Error); + this.Messaging.Write(we.Error); } catch (Exception e) { - Messaging.Instance.OnMessage(WixErrors.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace)); + this.Messaging.Write(ErrorMessages.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace)); } } @@ -133,7 +135,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// CabinetWorkItem containing information about the cabinet to create. private void CreateCabinet(CabinetWorkItem cabinetWorkItem) { - Messaging.Instance.OnMessage(WixVerboses.CreateCabinet(cabinetWorkItem.CabinetFile)); + this.Messaging.Write(VerboseMessages.CreateCabinet(cabinetWorkItem.CabinetFile)); int maxCabinetSize = 0; // The value of 0 corresponds to default of 2GB which means no cabinet splitting ulong maxPreCompressedSizeInBytes = 0; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs index 370d4b9c..cf8eb338 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs @@ -109,7 +109,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (ArgumentException) { - throw new WixException(WixErrors.IllegalCharactersInPath(path)); + throw new WixException(ErrorMessages.IllegalCharactersInPath(path)); } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs index 0c0aea1f..056f92a7 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs @@ -10,17 +10,21 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Core.Native; using WixToolset.Data; using WixToolset.Data.Tuples; + using WixToolset.Extensibility.Services; /// /// Set the guids for components with generatable guids. /// internal class CalculateComponentGuids { - public CalculateComponentGuids(IntermediateSection section) + public CalculateComponentGuids(IMessaging messaging, IntermediateSection section) { + this.Messaging = messaging; this.Section = section; } + private IMessaging Messaging { get; } + private IntermediateSection Section { get; } public void Execute() @@ -43,7 +47,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (String.IsNullOrEmpty(componentRow.KeyPath) || odbcDataSourceKeyPath) { - Messaging.Instance.OnMessage(WixErrors.IllegalComponentWithAutoGeneratedGuid(componentRow.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.IllegalComponentWithAutoGeneratedGuid(componentRow.SourceLineNumbers)); continue; } @@ -143,13 +147,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind path.StartsWith(@"StartMenuFolder\programs", StringComparison.Ordinal) || path.StartsWith(@"WindowsFolder\fonts", StringComparison.Ordinal)) { - Messaging.Instance.OnMessage(WixErrors.IllegalPathForGeneratedComponentGuid(componentRow.SourceLineNumbers, fileRow.Component_, path)); + this.Messaging.Write(ErrorMessages.IllegalPathForGeneratedComponentGuid(componentRow.SourceLineNumbers, fileRow.Component_, path)); } // if component has more than one file, the key path must be versioned if (1 < numFilesInComponent && String.IsNullOrEmpty(fileRow.Version)) { - Messaging.Instance.OnMessage(WixErrors.IllegalGeneratedGuidComponentUnversionedKeypath(componentRow.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.IllegalGeneratedGuidComponentUnversionedKeypath(componentRow.SourceLineNumbers)); } } else @@ -157,13 +161,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind // not a key path, so it must be an unversioned file if component has more than one file if (1 < numFilesInComponent && !String.IsNullOrEmpty(fileRow.Version)) { - Messaging.Instance.OnMessage(WixErrors.IllegalGeneratedGuidComponentVersionedNonkeypath(componentRow.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.IllegalGeneratedGuidComponentVersionedNonkeypath(componentRow.SourceLineNumbers)); } } } // if the rules were followed, reward with a generated guid - if (!Messaging.Instance.EncounteredError) + if (!this.Messaging.EncounteredError) { componentRow.ComponentId = Uuid.NewUuid(BindDatabaseCommand.WixComponentGuidNamespace, path).ToString("B").ToUpperInvariant(); } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CopyTransformDataCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CopyTransformDataCommand.cs index 559d440c..13408312 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CopyTransformDataCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CopyTransformDataCommand.cs @@ -12,13 +12,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Data.WindowsInstaller; using WixToolset.Data.WindowsInstaller.Rows; using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; internal class CopyTransformDataCommand { public bool CopyOutFileRows { private get; set; } public IEnumerable Extensions { private get; set; } - + + public IMessaging Messaging { private get; set; } + public Output Output { private get; set; } public TableDefinitionCollection TableDefinitions { private get; set; } @@ -465,14 +468,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (seqDuplicateFiles < seqInstallFiles) { - throw new WixException(WixErrors.InsertInvalidSequenceActionOrder(mainFileRow.SourceLineNumbers, iesTable.Name, "InstallFiles", "DuplicateFiles", wixPatchAction.Action)); + throw new WixException(ErrorMessages.InsertInvalidSequenceActionOrder(mainFileRow.SourceLineNumbers, iesTable.Name, "InstallFiles", "DuplicateFiles", wixPatchAction.Action)); } else { sequence = (seqDuplicateFiles + seqInstallFiles) / 2; if (seqInstallFiles == sequence || seqDuplicateFiles == sequence) { - throw new WixException(WixErrors.InsertSequenceNoSpace(mainFileRow.SourceLineNumbers, iesTable.Name, "InstallFiles", "DuplicateFiles", wixPatchAction.Action)); + throw new WixException(ErrorMessages.InsertSequenceNoSpace(mainFileRow.SourceLineNumbers, iesTable.Name, "InstallFiles", "DuplicateFiles", wixPatchAction.Action)); } } } @@ -579,7 +582,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Make sure all changes to non keypath files also had a change in the keypath. if (!componentWithChangedKeyPath.ContainsKey(componentFile.Key) && componentKeyPath.ContainsKey(componentFile.Key)) { - Messaging.Instance.OnMessage(WixWarnings.UpdateOfNonKeyPathFile((string)componentFile.Value, (string)componentFile.Key, (string)componentKeyPath[componentFile.Key])); + this.Messaging.Write(WarningMessages.UpdateOfNonKeyPathFile((string)componentFile.Value, (string)componentFile.Key, (string)componentKeyPath[componentFile.Key])); } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index 0aa50bd9..28e7f6df 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs @@ -16,6 +16,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Data.WindowsInstaller; using WixToolset.Data.WindowsInstaller.Rows; using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; /// /// Creates cabinet files. @@ -45,6 +46,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind public string CabCachePath { private get; set; } + public IMessaging Messaging { private get; set; } + public string TempFilesLocation { private get; set; } /// @@ -85,7 +88,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.SetCabbingThreadCount(); // Send Binder object to Facilitate NewCabNamesCallBack Callback - CabinetBuilder cabinetBuilder = new CabinetBuilder(this.CabbingThreadCount, Marshal.GetFunctionPointerForDelegate(this.newCabNamesCallBack)); + CabinetBuilder cabinetBuilder = new CabinetBuilder(this.Messaging, this.CabbingThreadCount, Marshal.GetFunctionPointerForDelegate(this.newCabNamesCallBack)); // Supply Compile MediaTemplate Attributes to Cabinet Builder this.GetMediaTemplateAttributes(out var MaximumCabinetSizeForLargeFileSplitting, out var MaximumUncompressedMediaSize); @@ -120,14 +123,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // stop processing if an error previously occurred - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } // create queued cabinets with multiple threads cabinetBuilder.CreateQueuedCabinets(); - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } @@ -152,7 +155,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (0 >= this.CabbingThreadCount) { - throw new WixException(WixErrors.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); + throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); } } else // default to 1 if the environment variable is not set @@ -160,15 +163,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.CabbingThreadCount = 1; } - Messaging.Instance.OnMessage(WixVerboses.SetCabbingThreadCount(this.CabbingThreadCount.ToString())); + this.Messaging.Write(VerboseMessages.SetCabbingThreadCount(this.CabbingThreadCount.ToString())); } catch (ArgumentException) { - throw new WixException(WixErrors.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); + throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); } catch (FormatException) { - throw new WixException(WixErrors.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); + throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); } } } @@ -202,11 +205,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind // If building a patch, remind them to run -p for torch. if (OutputType.Patch == output.Type) { - Messaging.Instance.OnMessage(WixWarnings.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName, true)); + this.Messaging.Write(WarningMessages.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName, true)); } else { - Messaging.Instance.OnMessage(WixWarnings.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName)); + this.Messaging.Write(WarningMessages.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName)); } } @@ -223,7 +226,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else // reuse the cabinet from the cabinet cache. { - Messaging.Instance.OnMessage(WixVerboses.ReusingCabCache(mediaRow.SourceLineNumbers, mediaRow.Cabinet, resolvedCabinet.Path)); + this.Messaging.Write(VerboseMessages.ReusingCabCache(mediaRow.SourceLineNumbers, mediaRow.Cabinet, resolvedCabinet.Path)); try { @@ -237,7 +240,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (Exception e) { - Messaging.Instance.OnMessage(WixWarnings.CannotUpdateCabCache(mediaRow.SourceLineNumbers, resolvedCabinet.Path, e.Message)); + this.Messaging.Write(WarningMessages.CannotUpdateCabCache(mediaRow.SourceLineNumbers, resolvedCabinet.Path, e.Message)); } } @@ -303,7 +306,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (!mutex.WaitOne(0, false)) // Check if you can get the lock { // Cound not get the Lock - Messaging.Instance.OnMessage(WixVerboses.CabinetsSplitInParallel()); + this.Messaging.Write(VerboseMessages.CabinetsSplitInParallel()); mutex.WaitOne(); // Wait on other thread } @@ -333,7 +336,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Check if File Transfer was added if (!transferAdded) { - throw new WixException(WixErrors.SplitCabinetCopyRegistrationFailed(newCabinetName, firstCabinetName)); + throw new WixException(ErrorMessages.SplitCabinetCopyRegistrationFailed(newCabinetName, firstCabinetName)); } // Add the new Cabinets to media table using LastSequence of Base Cabinet @@ -365,14 +368,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (newCabinetName.Equals(mediaRow.Cabinet, StringComparison.InvariantCultureIgnoreCase)) { // Name Collision of generated Split Cabinet Name and user Specified Cab name for current row - throw new WixException(WixErrors.SplitCabinetNameCollision(newCabinetName, firstCabinetName)); + throw new WixException(ErrorMessages.SplitCabinetNameCollision(newCabinetName, firstCabinetName)); } } // Check if the last Split Cabinet was found in the Media Table if (!lastSplitCabinetFound) { - throw new WixException(WixErrors.SplitCabinetInsertionFailed(newCabinetName, firstCabinetName, lastCabinetOfThisSequence)); + throw new WixException(ErrorMessages.SplitCabinetInsertionFailed(newCabinetName, firstCabinetName, lastCabinetOfThisSequence)); } // The new Row has to be inserted just after the last cab in this cabinet split chain according to DiskID Sort @@ -454,11 +457,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (FormatException) { - throw new WixException(WixErrors.IllegalEnvironmentVariable("WIX_MCSLFS", mcslfsString)); + throw new WixException(ErrorMessages.IllegalEnvironmentVariable("WIX_MCSLFS", mcslfsString)); } catch (OverflowException) { - throw new WixException(WixErrors.MaximumCabinetSizeForLargeFileSplittingTooLarge(null, maxCabSizeForLargeFileInMB, MaxValueOfMaxCabSizeForLargeFileSplitting)); + throw new WixException(ErrorMessages.MaximumCabinetSizeForLargeFileSplittingTooLarge(null, maxCabSizeForLargeFileInMB, MaxValueOfMaxCabSizeForLargeFileSplitting)); } try @@ -476,11 +479,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (FormatException) { - throw new WixException(WixErrors.IllegalEnvironmentVariable("WIX_MUMS", mumsString)); + throw new WixException(ErrorMessages.IllegalEnvironmentVariable("WIX_MUMS", mumsString)); } catch (OverflowException) { - throw new WixException(WixErrors.MaximumUncompressedMediaSizeTooLarge(null, maxPreCompressedSizeInMB)); + throw new WixException(ErrorMessages.MaximumUncompressedMediaSizeTooLarge(null, maxPreCompressedSizeInMB)); } maxCabSizeForLargeFileSplitting = maxCabSizeForLargeFileInMB; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs index 1fc7d068..9afb3260 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs @@ -8,17 +8,21 @@ namespace WixToolset.Core.WindowsInstaller.Bind using System.Text; using WixToolset.Data; using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility.Services; internal class CreateIdtFileCommand { - public CreateIdtFileCommand(Table table, int codepage, string intermediateFolder, bool keepAddedColumns) + public CreateIdtFileCommand(IMessaging messaging, Table table, int codepage, string intermediateFolder, bool keepAddedColumns) { + this.Messaging = messaging; this.Table = table; this.Codepage = codepage; this.IntermediateFolder = intermediateFolder; this.KeepAddedColumns = keepAddedColumns; } + private IMessaging Messaging { get; } + private Table Table { get; } private int Codepage { get; set; } @@ -67,7 +71,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (TableDefinition.MaxColumnsInRealTable < table.Definition.Columns.Count) { - throw new WixException(WixDataErrors.TooManyColumnsInRealTable(table.Definition.Name, table.Definition.Columns.Count, TableDefinition.MaxColumnsInRealTable)); + throw new WixException(ErrorMessages.TooManyColumnsInRealTable(table.Definition.Name, table.Definition.Columns.Count, TableDefinition.MaxColumnsInRealTable)); } // Tack on the table header, and flush before we start writing bytes directly to the stream. @@ -98,7 +102,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (EncoderFallbackException) { - Messaging.Instance.OnMessage(WixDataErrors.InvalidStringForCodepage(row.SourceLineNumbers, Convert.ToString(writer.Encoding.WindowsCodePage, CultureInfo.InvariantCulture))); + this.Messaging.Write(ErrorMessages.InvalidStringForCodepage(row.SourceLineNumbers, Convert.ToString(writer.Encoding.WindowsCodePage, CultureInfo.InvariantCulture))); rowBytes = convertEncoding.GetBytes(rowString); } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs index a31c8079..e1777246 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs @@ -15,18 +15,22 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Core.Native; using WixToolset.Core.Bind; using WixToolset.Data.Tuples; + using WixToolset.Extensibility.Services; /// /// Retrieve files information and extract them from merge modules. /// internal class ExtractMergeModuleFilesCommand { - public ExtractMergeModuleFilesCommand(IntermediateSection section, List wixMergeTuples) + public ExtractMergeModuleFilesCommand(IMessaging messaging, IntermediateSection section, List wixMergeTuples) { + this.Messaging = messaging; this.Section = section; this.WixMergeTuples = wixMergeTuples; } + private IMessaging Messaging { get; } + private IntermediateSection Section { get; } private List WixMergeTuples { get; } @@ -121,11 +125,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind // If case-sensitive collision with another merge module or a user-authored file identifier. if (indexedFileFacades.TryGetValue(mergeModuleFileFacade.File.File, out var collidingFacade)) { - Messaging.Instance.OnMessage(WixErrors.DuplicateModuleFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, collidingFacade.File.File)); + this.Messaging.Write(ErrorMessages.DuplicateModuleFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, collidingFacade.File.File)); } else if (uniqueModuleFileIdentifiers.TryGetValue(mergeModuleFileFacade.File.File, out collidingFacade)) // case-insensitive collision with another file identifier in the same merge module { - Messaging.Instance.OnMessage(WixErrors.DuplicateModuleCaseInsensitiveFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, mergeModuleFileFacade.File.File, collidingFacade.File.File)); + this.Messaging.Write(ErrorMessages.DuplicateModuleCaseInsensitiveFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, mergeModuleFileFacade.File.File, collidingFacade.File.File)); } else // no collision { @@ -152,23 +156,23 @@ namespace WixToolset.Core.WindowsInstaller.Bind int moduleInstallerVersion = Convert.ToInt32(moduleInstallerVersionString, CultureInfo.InvariantCulture); if (moduleInstallerVersion > this.OutputInstallerVersion) { - Messaging.Instance.OnMessage(WixWarnings.InvalidHigherInstallerVersionInModule(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, moduleInstallerVersion, this.OutputInstallerVersion)); + this.Messaging.Write(WarningMessages.InvalidHigherInstallerVersionInModule(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, moduleInstallerVersion, this.OutputInstallerVersion)); } } catch (FormatException) { - throw new WixException(WixErrors.MissingOrInvalidModuleInstallerVersion(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, wixMergeRow.SourceFile, moduleInstallerVersionString)); + throw new WixException(ErrorMessages.MissingOrInvalidModuleInstallerVersion(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, wixMergeRow.SourceFile, moduleInstallerVersionString)); } } } } catch (FileNotFoundException) { - throw new WixException(WixErrors.FileNotFound(wixMergeRow.SourceLineNumbers, wixMergeRow.SourceFile)); + throw new WixException(ErrorMessages.FileNotFound(wixMergeRow.SourceLineNumbers, wixMergeRow.SourceFile)); } catch (Win32Exception) { - throw new WixException(WixErrors.CannotOpenMergeModule(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, wixMergeRow.SourceFile)); + throw new WixException(ErrorMessages.CannotOpenMergeModule(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, wixMergeRow.SourceFile)); } return containsFiles; @@ -187,7 +191,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (FormatException) { - Messaging.Instance.OnMessage(WixErrors.InvalidMergeLanguage(wixMergeRow.SourceLineNumbers, mergeId, wixMergeRow.Language.ToString())); + this.Messaging.Write(ErrorMessages.InvalidMergeLanguage(wixMergeRow.SourceLineNumbers, mergeId, wixMergeRow.Language.ToString())); return; } @@ -210,16 +214,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (FileNotFoundException) { - throw new WixException(WixErrors.CabFileDoesNotExist(moduleCabPath, wixMergeRow.SourceFile, mergeIdPath)); + throw new WixException(ErrorMessages.CabFileDoesNotExist(moduleCabPath, wixMergeRow.SourceFile, mergeIdPath)); } catch { - throw new WixException(WixErrors.CabExtractionFailed(moduleCabPath, wixMergeRow.SourceFile, mergeIdPath)); + throw new WixException(ErrorMessages.CabExtractionFailed(moduleCabPath, wixMergeRow.SourceFile, mergeIdPath)); } } catch (COMException ce) { - throw new WixException(WixErrors.UnableToOpenModule(wixMergeRow.SourceLineNumbers, wixMergeRow.SourceFile, ce.Message)); + throw new WixException(ErrorMessages.UnableToOpenModule(wixMergeRow.SourceLineNumbers, wixMergeRow.SourceFile, ce.Message)); } finally { diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs index e4e66559..ee7cc61b 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs @@ -13,6 +13,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Msi; using WixToolset.Core.Native; using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility.Services; internal class GenerateDatabaseCommand { @@ -25,6 +26,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// public bool KeepAddedColumns { private get; set; } + public IMessaging Messaging { private get; set; } + public Output Output { private get; set; } public string OutputPath { private get; set; } @@ -177,7 +180,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind try { //db.ImportTable(this.Output.Codepage, importTable, baseDirectory, this.KeepAddedColumns); - var command = new CreateIdtFileCommand(importTable, this.Output.Codepage, baseDirectory, this.KeepAddedColumns); + var command = new CreateIdtFileCommand(this.Messaging, importTable, this.Output.Codepage, baseDirectory, this.KeepAddedColumns); command.Execute(); db.Import(command.IdtPath); @@ -262,11 +265,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (0xA1 == e.NativeErrorCode) // ERROR_BAD_PATHNAME { - throw new WixException(WixErrors.FileNotFound(row.SourceLineNumbers, (string)row[i])); + throw new WixException(ErrorMessages.FileNotFound(row.SourceLineNumbers, (string)row[i])); } else { - throw new WixException(WixErrors.Win32Exception(e.NativeErrorCode, e.Message)); + throw new WixException(ErrorMessages.Win32Exception(e.NativeErrorCode, e.Message)); } } } @@ -279,7 +282,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // check for a stream name that is more than 62 characters long (the maximum allowed length) if (needStream && MsiInterop.MsiMaxStreamNameLength < streamName.Length) { - Messaging.Instance.OnMessage(WixErrors.StreamNameTooLong(row.SourceLineNumbers, table.Name, streamName.ToString(), streamName.Length)); + this.Messaging.Write(ErrorMessages.StreamNameTooLong(row.SourceLineNumbers, table.Name, streamName.ToString(), streamName.Length)); } else // add the row to the database { @@ -309,7 +312,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Bind the transform. this.BindTransform(subStorage.Data, transformFile); - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { continue; } @@ -338,7 +341,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind private void BindTransform(Output transform, string outputPath) { - BindTransformCommand command = new BindTransformCommand(); + var command = new BindTransformCommand(); + command.Messaging = this.Messaging; command.Extensions = this.Extensions; command.TempFilesLocation = this.TempFilesLocation; command.Transform = transform; @@ -372,7 +376,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind catch (WixInvalidIdtException) { // the IDT should be valid, so an invalid code page was given - throw new WixException(WixErrors.IllegalCodepage(codepage)); + throw new WixException(ErrorMessages.IllegalCodepage(codepage)); } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs index 32a05d93..8d1edb41 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs @@ -13,6 +13,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Data; using WixToolset.Data.WindowsInstaller; using WixToolset.Data.WindowsInstaller.Rows; + using WixToolset.Extensibility.Services; using WixToolset.MergeMod; using WixToolset.Msi; @@ -23,6 +24,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind { public IEnumerable FileFacades { private get; set; } + public IMessaging Messaging { private get; set; } + public Output Output { private get; set; } public string OutputPath { private get; set; } @@ -73,11 +76,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (FormatException) { - Messaging.Instance.OnMessage(WixErrors.InvalidMergeLanguage(wixMergeRow.SourceLineNumbers, wixMergeRow.Id, wixMergeRow.Language)); + this.Messaging.Write(ErrorMessages.InvalidMergeLanguage(wixMergeRow.SourceLineNumbers, wixMergeRow.Id, wixMergeRow.Language)); continue; } - Messaging.Instance.OnMessage(WixVerboses.OpeningMergeModule(wixMergeRow.SourceFile, mergeLanguage)); + this.Messaging.Write(VerboseMessages.OpeningMergeModule(wixMergeRow.SourceFile, mergeLanguage)); merge.OpenModule(wixMergeRow.SourceFile, mergeLanguage); moduleOpen = true; @@ -89,7 +92,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // merge the module into the database that's being built - Messaging.Instance.OnMessage(WixVerboses.MergingMergeModule(wixMergeRow.SourceFile)); + this.Messaging.Write(VerboseMessages.MergingMergeModule(wixMergeRow.SourceFile)); merge.MergeEx(wixMergeRow.Feature, wixMergeRow.Directory, callback); // connect any non-primary features @@ -99,7 +102,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (wixMergeRow.Id == (string)row[1]) { - Messaging.Instance.OnMessage(WixVerboses.ConnectingMergeModule(wixMergeRow.SourceFile, (string)row[0])); + this.Messaging.Write(VerboseMessages.ConnectingMergeModule(wixMergeRow.SourceFile, (string)row[0])); merge.Connect((string)row[0]); } } @@ -144,38 +147,38 @@ namespace WixToolset.Core.WindowsInstaller.Bind switch (mergeError.Type) { case MsmErrorType.msmErrorExclusion: - Messaging.Instance.OnMessage(WixErrors.MergeExcludedModule(wixMergeRow.SourceLineNumbers, wixMergeRow.Id, moduleKeys.ToString())); + this.Messaging.Write(ErrorMessages.MergeExcludedModule(wixMergeRow.SourceLineNumbers, wixMergeRow.Id, moduleKeys.ToString())); break; case MsmErrorType.msmErrorFeatureRequired: - Messaging.Instance.OnMessage(WixErrors.MergeFeatureRequired(wixMergeRow.SourceLineNumbers, mergeError.ModuleTable, moduleKeys.ToString(), wixMergeRow.SourceFile, wixMergeRow.Id)); + this.Messaging.Write(ErrorMessages.MergeFeatureRequired(wixMergeRow.SourceLineNumbers, mergeError.ModuleTable, moduleKeys.ToString(), wixMergeRow.SourceFile, wixMergeRow.Id)); break; case MsmErrorType.msmErrorLanguageFailed: - Messaging.Instance.OnMessage(WixErrors.MergeLanguageFailed(wixMergeRow.SourceLineNumbers, mergeError.Language, wixMergeRow.SourceFile)); + this.Messaging.Write(ErrorMessages.MergeLanguageFailed(wixMergeRow.SourceLineNumbers, mergeError.Language, wixMergeRow.SourceFile)); break; case MsmErrorType.msmErrorLanguageUnsupported: - Messaging.Instance.OnMessage(WixErrors.MergeLanguageUnsupported(wixMergeRow.SourceLineNumbers, mergeError.Language, wixMergeRow.SourceFile)); + this.Messaging.Write(ErrorMessages.MergeLanguageUnsupported(wixMergeRow.SourceLineNumbers, mergeError.Language, wixMergeRow.SourceFile)); break; case MsmErrorType.msmErrorResequenceMerge: - Messaging.Instance.OnMessage(WixWarnings.MergeRescheduledAction(wixMergeRow.SourceLineNumbers, mergeError.DatabaseTable, databaseKeys.ToString(), wixMergeRow.SourceFile)); + this.Messaging.Write(WarningMessages.MergeRescheduledAction(wixMergeRow.SourceLineNumbers, mergeError.DatabaseTable, databaseKeys.ToString(), wixMergeRow.SourceFile)); break; case MsmErrorType.msmErrorTableMerge: if ("_Validation" != mergeError.DatabaseTable) // ignore merge errors in the _Validation table { - Messaging.Instance.OnMessage(WixWarnings.MergeTableFailed(wixMergeRow.SourceLineNumbers, mergeError.DatabaseTable, databaseKeys.ToString(), wixMergeRow.SourceFile)); + this.Messaging.Write(WarningMessages.MergeTableFailed(wixMergeRow.SourceLineNumbers, mergeError.DatabaseTable, databaseKeys.ToString(), wixMergeRow.SourceFile)); } break; case MsmErrorType.msmErrorPlatformMismatch: - Messaging.Instance.OnMessage(WixErrors.MergePlatformMismatch(wixMergeRow.SourceLineNumbers, wixMergeRow.SourceFile)); + this.Messaging.Write(ErrorMessages.MergePlatformMismatch(wixMergeRow.SourceLineNumbers, wixMergeRow.SourceFile)); break; default: - Messaging.Instance.OnMessage(WixErrors.UnexpectedException(String.Format(CultureInfo.CurrentUICulture, WixStrings.EXP_UnexpectedMergerErrorWithType, Enum.GetName(typeof(MsmErrorType), mergeError.Type), logPath), "InvalidOperationException", Environment.StackTrace)); + this.Messaging.Write(ErrorMessages.UnexpectedException(String.Format(CultureInfo.CurrentUICulture, WixStrings.EXP_UnexpectedMergerErrorWithType, Enum.GetName(typeof(MsmErrorType), mergeError.Type), logPath), "InvalidOperationException", Environment.StackTrace)); break; } } if (0 >= mergeErrors.Count && !commit) { - Messaging.Instance.OnMessage(WixErrors.UnexpectedException(String.Format(CultureInfo.CurrentUICulture, WixStrings.EXP_UnexpectedMergerErrorInSourceFile, wixMergeRow.SourceFile, logPath), "InvalidOperationException", Environment.StackTrace)); + this.Messaging.Write(ErrorMessages.UnexpectedException(String.Format(CultureInfo.CurrentUICulture, WixStrings.EXP_UnexpectedMergerErrorInSourceFile, wixMergeRow.SourceFile, logPath), "InvalidOperationException", Environment.StackTrace)); } if (moduleOpen) @@ -199,7 +202,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // stop processing if an error previously occurred - if (Messaging.Instance.EncounteredError) + if (this.Messaging.EncounteredError) { return; } @@ -223,7 +226,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (null != record) { - Messaging.Instance.OnMessage(WixWarnings.SuppressMergedAction((string)row[1], row[0].ToString())); + this.Messaging.Write(WarningMessages.SuppressMergedAction((string)row[1], row[0].ToString())); view.Modify(ModifyView.Delete, record); } } @@ -251,7 +254,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind break; } - Messaging.Instance.OnMessage(WixWarnings.SuppressMergedAction(resultRecord.GetString(1), tableName)); + this.Messaging.Write(WarningMessages.SuppressMergedAction(resultRecord.GetString(1), tableName)); } } } @@ -273,7 +276,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // now update the Attributes column for the files from the Merge Modules - Messaging.Instance.OnMessage(WixVerboses.ResequencingMergeModuleFiles()); + this.Messaging.Write(VerboseMessages.ResequencingMergeModuleFiles()); using (View view = db.OpenView("SELECT `Sequence`, `Attributes` FROM `File` WHERE `File`=?")) { foreach (var file in this.FileFacades) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs index aa4382f5..e1a26a67 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs @@ -97,7 +97,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (null == fileRecord) { - throw new WixException(WixErrors.FileIdentifierNotFound(facade.File.SourceLineNumbers, facade.File.File)); + throw new WixException(ErrorMessages.FileIdentifierNotFound(facade.File.SourceLineNumbers, facade.File.File)); } relativeFileLayoutPath = Binder.GetFileSourcePath(directories, fileRecord[1], fileRecord[2], this.Compressed, this.LongNamesInImage); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs index cf9c0332..47eb9408 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs @@ -9,6 +9,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Core.Native; using WixToolset.Data; using WixToolset.Data.Tuples; + using WixToolset.Extensibility.Services; internal class SequenceActionsCommand { @@ -27,7 +28,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind private Dictionary StandardActionsById { get; } - public Messaging Messaging { private get; set; } + public IMessaging Messaging { private get; set; } public void Execute() { @@ -64,10 +65,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (overridableActionRows.TryGetValue(actionRow.Id.Id, out var collidingActionRow)) { - this.Messaging.OnMessage(WixErrors.OverridableActionCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); + this.Messaging.Write(ErrorMessages.OverridableActionCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); if (null != collidingActionRow.SourceLineNumbers) { - this.Messaging.OnMessage(WixErrors.OverridableActionCollision2(collidingActionRow.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.OverridableActionCollision2(collidingActionRow.SourceLineNumbers)); } } else @@ -93,10 +94,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (overridableActionRows.TryGetValue(actionRow.Id.Id, out var collidingActionRow)) { - this.Messaging.OnMessage(WixErrors.ActionCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); + this.Messaging.Write(ErrorMessages.ActionCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); if (null != collidingActionRow.SourceLineNumbers) { - this.Messaging.OnMessage(WixErrors.ActionCollision2(collidingActionRow.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.ActionCollision2(collidingActionRow.SourceLineNumbers)); } } else @@ -127,20 +128,20 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (requiredActionRow.Overridable) { - this.Messaging.OnMessage(WixWarnings.SuppressAction(suppressActionRow.SourceLineNumbers, suppressActionRow.Action, suppressActionRow.SequenceTable.ToString())); + this.Messaging.Write(WarningMessages.SuppressAction(suppressActionRow.SourceLineNumbers, suppressActionRow.Action, suppressActionRow.SequenceTable.ToString())); if (null != requiredActionRow.SourceLineNumbers) { - this.Messaging.OnMessage(WixWarnings.SuppressAction2(requiredActionRow.SourceLineNumbers)); + this.Messaging.Write(WarningMessages.SuppressAction2(requiredActionRow.SourceLineNumbers)); } requiredActionRows.Remove(key); } else // suppressing a non-overridable action row { - this.Messaging.OnMessage(WixErrors.SuppressNonoverridableAction(suppressActionRow.SourceLineNumbers, suppressActionRow.SequenceTable.ToString(), suppressActionRow.Action)); + this.Messaging.Write(ErrorMessages.SuppressNonoverridableAction(suppressActionRow.SourceLineNumbers, suppressActionRow.SequenceTable.ToString(), suppressActionRow.Action)); if (null != requiredActionRow.SourceLineNumbers) { - this.Messaging.OnMessage(WixErrors.SuppressNonoverridableAction2(requiredActionRow.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.SuppressNonoverridableAction2(requiredActionRow.SourceLineNumbers)); } } } @@ -156,14 +157,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind // check for standard actions that don't have a sequence number in a merge module if (SectionType.Module == this.Section.Type && WindowsInstallerStandard.IsStandardAction(actionRow.Action)) { - this.Messaging.OnMessage(WixErrors.StandardActionRelativelyScheduledInModule(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); + this.Messaging.Write(ErrorMessages.StandardActionRelativelyScheduledInModule(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); } this.SequenceActionRow(actionRow, requiredActionRows); } else if (SectionType.Module == this.Section.Type && 0 < actionRow.Sequence && !WindowsInstallerStandard.IsStandardAction(actionRow.Action)) // check for custom actions and dialogs that have a sequence number { - this.Messaging.OnMessage(WixErrors.CustomActionSequencedInModule(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); + this.Messaging.Write(ErrorMessages.CustomActionSequencedInModule(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action)); } } @@ -231,10 +232,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (sequenceScheduledActionRow.Sequence == actionRow.Sequence) { - this.Messaging.OnMessage(WixWarnings.ActionSequenceCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, sequenceScheduledActionRow.Action, actionRow.Sequence)); + this.Messaging.Write(WarningMessages.ActionSequenceCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, sequenceScheduledActionRow.Action, actionRow.Sequence)); if (null != sequenceScheduledActionRow.SourceLineNumbers) { - this.Messaging.OnMessage(WixWarnings.ActionSequenceCollision2(sequenceScheduledActionRow.SourceLineNumbers)); + this.Messaging.Write(WarningMessages.ActionSequenceCollision2(sequenceScheduledActionRow.SourceLineNumbers)); } } } @@ -262,19 +263,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Create errors for all the before actions. foreach (var actionRow in relativeActions.PreviousActions) { - this.Messaging.OnMessage(WixErrors.ActionScheduledRelativeToTerminationAction(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, absoluteActionRow.Action)); + this.Messaging.Write(ErrorMessages.ActionScheduledRelativeToTerminationAction(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, absoluteActionRow.Action)); } // Create errors for all the after actions. foreach (var actionRow in relativeActions.NextActions) { - this.Messaging.OnMessage(WixErrors.ActionScheduledRelativeToTerminationAction(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, absoluteActionRow.Action)); + this.Messaging.Write(ErrorMessages.ActionScheduledRelativeToTerminationAction(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, absoluteActionRow.Action)); } // If there is source line information for the absolutely scheduled action display it if (absoluteActionRow.SourceLineNumbers != null) { - this.Messaging.OnMessage(WixErrors.ActionScheduledRelativeToTerminationAction2(absoluteActionRow.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.ActionScheduledRelativeToTerminationAction2(absoluteActionRow.SourceLineNumbers)); } continue; @@ -289,10 +290,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind // look for collisions if (unusedSequence == previousUsedSequence) { - this.Messaging.OnMessage(WixErrors.NoUniqueActionSequenceNumber(relativeActionRow.SourceLineNumbers, relativeActionRow.SequenceTable.ToString(), relativeActionRow.Action, absoluteActionRow.Action)); + this.Messaging.Write(ErrorMessages.NoUniqueActionSequenceNumber(relativeActionRow.SourceLineNumbers, relativeActionRow.SequenceTable.ToString(), relativeActionRow.Action, absoluteActionRow.Action)); if (absoluteActionRow.SourceLineNumbers != null) { - this.Messaging.OnMessage(WixErrors.NoUniqueActionSequenceNumber2(absoluteActionRow.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.NoUniqueActionSequenceNumber2(absoluteActionRow.SourceLineNumbers)); } unusedSequence++; @@ -319,10 +320,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (unusedSequence == nextUsedSequence) { - this.Messaging.OnMessage(WixErrors.NoUniqueActionSequenceNumber(relativeActionRow.SourceLineNumbers, relativeActionRow.SequenceTable.ToString(), relativeActionRow.Action, absoluteActionRow.Action)); + this.Messaging.Write(ErrorMessages.NoUniqueActionSequenceNumber(relativeActionRow.SourceLineNumbers, relativeActionRow.SequenceTable.ToString(), relativeActionRow.Action, absoluteActionRow.Action)); if (absoluteActionRow.SourceLineNumbers != null) { - this.Messaging.OnMessage(WixErrors.NoUniqueActionSequenceNumber2(absoluteActionRow.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.NoUniqueActionSequenceNumber2(absoluteActionRow.SourceLineNumbers)); } unusedSequence--; @@ -596,7 +597,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else if (actionRow == parentActionRow || this.ContainsChildActionRow(actionRow, parentActionRow)) // cycle detected { - throw new WixException(WixErrors.ActionCircularDependency(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, parentActionRow.Action)); + throw new WixException(ErrorMessages.ActionCircularDependency(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, parentActionRow.Action)); } // Add this action to the appropriate list of dependent action rows. diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs index dddc9380..3ad2470f 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateControlTextCommand.cs @@ -7,9 +7,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Data; using WixToolset.Data.WindowsInstaller; using WixToolset.Data.WindowsInstaller.Rows; + using WixToolset.Extensibility.Services; internal class UpdateControlTextCommand { + public IMessaging Messaging { private get; set; } + public Table BBControlTable { private get; set; } public Table WixBBControlTable { private get; set; } @@ -60,19 +63,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (DirectoryNotFoundException e) { - Messaging.Instance.OnMessage(WixErrors.BinderFileManagerMissingFile(sourceLineNumbers, e.Message)); + this.Messaging.Write(ErrorMessages.BinderFileManagerMissingFile(sourceLineNumbers, e.Message)); } catch (FileNotFoundException e) { - Messaging.Instance.OnMessage(WixErrors.BinderFileManagerMissingFile(sourceLineNumbers, e.Message)); + this.Messaging.Write(ErrorMessages.BinderFileManagerMissingFile(sourceLineNumbers, e.Message)); } catch (IOException e) { - Messaging.Instance.OnMessage(WixErrors.BinderFileManagerMissingFile(sourceLineNumbers, e.Message)); + this.Messaging.Write(ErrorMessages.BinderFileManagerMissingFile(sourceLineNumbers, e.Message)); } catch (NotSupportedException) { - Messaging.Instance.OnMessage(WixErrors.FileNotFound(sourceLineNumbers, source)); + this.Messaging.Write(ErrorMessages.FileNotFound(sourceLineNumbers, source)); } return text; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs index cf620e72..10eae8f8 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs @@ -15,6 +15,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Data; using WixToolset.Data.Tuples; using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility.Services; using WixToolset.Msi; /// @@ -22,11 +23,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// internal class UpdateFileFacadesCommand { - public UpdateFileFacadesCommand(IntermediateSection section) + public UpdateFileFacadesCommand(IMessaging messaging, IntermediateSection section) { + this.Messaging = messaging; this.Section = section; } + private IMessaging Messaging { get; } + private IntermediateSection Section { get; } public IEnumerable FileFacades { private get; set; } @@ -62,23 +66,23 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (ArgumentException) { - Messaging.Instance.OnMessage(WixDataErrors.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); + this.Messaging.Write(ErrorMessages.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); return; } catch (PathTooLongException) { - Messaging.Instance.OnMessage(WixDataErrors.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); + this.Messaging.Write(ErrorMessages.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); return; } catch (NotSupportedException) { - Messaging.Instance.OnMessage(WixDataErrors.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); + this.Messaging.Write(ErrorMessages.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); return; } if (!fileInfo.Exists) { - Messaging.Instance.OnMessage(WixErrors.CannotFindFile(file.File.SourceLineNumbers, file.File.File, file.File.LongFileName, file.WixFile.Source.Path)); + this.Messaging.Write(ErrorMessages.CannotFindFile(file.File.SourceLineNumbers, file.File.File, file.File.LongFileName, file.WixFile.Source.Path)); return; } @@ -86,7 +90,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (Int32.MaxValue < fileStream.Length) { - throw new WixException(WixErrors.FileTooLarge(file.File.SourceLineNumbers, file.WixFile.Source.Path)); + throw new WixException(ErrorMessages.FileTooLarge(file.File.SourceLineNumbers, file.WixFile.Source.Path)); } file.File.FileSize = Convert.ToInt32(fileStream.Length, CultureInfo.InvariantCulture); @@ -102,11 +106,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (0x2 == e.NativeErrorCode) // ERROR_FILE_NOT_FOUND { - throw new WixException(WixErrors.FileNotFound(file.File.SourceLineNumbers, fileInfo.FullName)); + throw new WixException(ErrorMessages.FileNotFound(file.File.SourceLineNumbers, fileInfo.FullName)); } else { - throw new WixException(WixErrors.Win32Exception(e.NativeErrorCode, e.Message)); + throw new WixException(ErrorMessages.Win32Exception(e.NativeErrorCode, e.Message)); } } @@ -128,14 +132,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind // for unversioned file. That's allowed but generally a dangerous thing to do so let's point that out to the user. if (!this.FileFacades.Any(r => file.File.Version.Equals(r.File.File, StringComparison.Ordinal))) { - Messaging.Instance.OnMessage(WixWarnings.DefaultVersionUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Version, file.File.File)); + this.Messaging.Write(WarningMessages.DefaultVersionUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Version, file.File.File)); } } else { if (null != file.File.Language) { - Messaging.Instance.OnMessage(WixWarnings.DefaultLanguageUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.File)); + this.Messaging.Write(WarningMessages.DefaultLanguageUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.File)); } int[] hash; @@ -147,11 +151,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (0x2 == e.NativeErrorCode) // ERROR_FILE_NOT_FOUND { - throw new WixException(WixErrors.FileNotFound(file.File.SourceLineNumbers, fileInfo.FullName)); + throw new WixException(ErrorMessages.FileNotFound(file.File.SourceLineNumbers, fileInfo.FullName)); } else { - throw new WixException(WixErrors.Win32Exception(e.NativeErrorCode, fileInfo.FullName, e.Message)); + throw new WixException(ErrorMessages.Win32Exception(e.NativeErrorCode, fileInfo.FullName, e.Message)); } } @@ -193,7 +197,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (!String.IsNullOrEmpty(file.File.Language) && String.IsNullOrEmpty(language)) { - Messaging.Instance.OnMessage(WixWarnings.DefaultLanguageUsedForVersionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.File)); + this.Messaging.Write(WarningMessages.DefaultLanguageUsedForVersionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.File)); } else // override the default provided by the user (usually nothing) with the actual language from the file itself. { @@ -260,7 +264,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else if (file.WixFile.File_AssemblyApplication == null) { - throw new WixException(WixErrors.GacAssemblyNoStrongName(file.File.SourceLineNumbers, fileInfo.FullName, file.File.Component_)); + throw new WixException(ErrorMessages.GacAssemblyNoStrongName(file.File.SourceLineNumbers, fileInfo.FullName, file.File.Component_)); } string assemblyVersion = referenceIdentity.GetAttribute(null, "Version"); @@ -271,7 +275,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - Messaging.Instance.OnMessage(WixErrors.InvalidAssemblyFile(file.File.SourceLineNumbers, fileInfo.FullName, String.Format(CultureInfo.InvariantCulture, "HRESULT: 0x{0:x8}", result))); + this.Messaging.Write(ErrorMessages.InvalidAssemblyFile(file.File.SourceLineNumbers, fileInfo.FullName, String.Format(CultureInfo.InvariantCulture, "HRESULT: 0x{0:x8}", result))); return; } @@ -360,7 +364,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind FileFacade fileManifest = this.FileFacades.SingleOrDefault(r => r.File.File.Equals(file.WixFile.File_AssemblyManifest, StringComparison.Ordinal)); if (null == fileManifest) { - Messaging.Instance.OnMessage(WixErrors.MissingManifestForWin32Assembly(file.File.SourceLineNumbers, file.File.File, file.WixFile.File_AssemblyManifest)); + this.Messaging.Write(ErrorMessages.MissingManifestForWin32Assembly(file.File.SourceLineNumbers, file.File.File, file.WixFile.File_AssemblyManifest)); } string win32Type = null; @@ -397,7 +401,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } if (!hasNextSibling) { - Messaging.Instance.OnMessage(WixErrors.InvalidManifestContent(file.File.SourceLineNumbers, fileManifest.WixFile.Source.Path)); + this.Messaging.Write(ErrorMessages.InvalidManifestContent(file.File.SourceLineNumbers, fileManifest.WixFile.Source.Path)); return; } @@ -435,11 +439,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (FileNotFoundException fe) { - Messaging.Instance.OnMessage(WixErrors.FileNotFound(new SourceLineNumber(fileManifest.WixFile.Source.Path), fe.FileName, "AssemblyManifest")); + this.Messaging.Write(ErrorMessages.FileNotFound(new SourceLineNumber(fileManifest.WixFile.Source.Path), fe.FileName, "AssemblyManifest")); } catch (XmlException xe) { - Messaging.Instance.OnMessage(WixErrors.InvalidXml(new SourceLineNumber(fileManifest.WixFile.Source.Path), "manifest", xe.Message)); + this.Messaging.Write(ErrorMessages.InvalidXml(new SourceLineNumber(fileManifest.WixFile.Source.Path), "manifest", xe.Message)); } if (!String.IsNullOrEmpty(win32Name)) @@ -482,7 +486,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // check for null value (this can occur when grabbing the file version from an assembly without one) if (String.IsNullOrEmpty(value)) { - Messaging.Instance.OnMessage(WixWarnings.NullMsiAssemblyNameValue(file.File.SourceLineNumbers, file.File.Component_, name)); + this.Messaging.Write(WarningMessages.NullMsiAssemblyNameValue(file.File.SourceLineNumbers, file.File.Component_, name)); } else { @@ -491,7 +495,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind String.IsNullOrEmpty(file.WixFile.File_AssemblyApplication) && !String.Equals(Path.GetFileNameWithoutExtension(file.File.LongFileName), value, StringComparison.OrdinalIgnoreCase)) { - Messaging.Instance.OnMessage(WixErrors.GACAssemblyIdentityWarning(file.File.SourceLineNumbers, Path.GetFileNameWithoutExtension(file.File.LongFileName), value)); + this.Messaging.Write(ErrorMessages.GACAssemblyIdentityWarning(file.File.SourceLineNumbers, Path.GetFileNameWithoutExtension(file.File.LongFileName), value)); } // override directly authored value -- cgit v1.2.3-55-g6feb