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 ++-- .../Data/Xsd/actions.xsd | 73 ++++++ .../Data/Xsd/tables.xsd | 248 +++++++++++++++++++++ src/WixToolset.Core.WindowsInstaller/Differ.cs | 30 +-- .../Inscribe/InscribeMsiPackageCommand.cs | 14 +- src/WixToolset.Core.WindowsInstaller/MelterCore.cs | 4 +- .../Msi/WixInvalidIdtException.cs | 4 +- src/WixToolset.Core.WindowsInstaller/Patch.cs | 9 - .../PatchTransform.cs | 11 +- .../Unbind/ExtractCabinetsCommand.cs | 2 +- .../Unbind/UnbindDatabaseCommand.cs | 9 +- .../Unbind/UnbindTranformCommand.cs | 7 +- .../UnbindContext.cs | 7 +- src/WixToolset.Core.WindowsInstaller/Unbinder.cs | 4 +- src/WixToolset.Core.WindowsInstaller/Validator.cs | 42 ++-- .../ValidatorExtension.cs | 36 +-- .../WindowsInstallerStandardInternal.cs | 4 +- 32 files changed, 603 insertions(+), 271 deletions(-) create mode 100644 src/WixToolset.Core.WindowsInstaller/Data/Xsd/actions.xsd create mode 100644 src/WixToolset.Core.WindowsInstaller/Data/Xsd/tables.xsd (limited to 'src/WixToolset.Core.WindowsInstaller') 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 diff --git a/src/WixToolset.Core.WindowsInstaller/Data/Xsd/actions.xsd b/src/WixToolset.Core.WindowsInstaller/Data/Xsd/actions.xsd new file mode 100644 index 00000000..bf0ccb95 --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Data/Xsd/actions.xsd @@ -0,0 +1,73 @@ + + + + + + + + Schema for describing standard actions in the Windows Installer. + + + + + + + + + + + + + + + + Name of action + + + + + Default condition for action + + + + + Sequence of action + + + + + Specifies if action is allowed in AdminExecuteSequence + + + + + Specifies if action is allowed in AdminUISequence + + + + + Specifies if action is allowed in AdvtExecuteSequence + + + + + Specifies if action is allowed in InstallExecuteSequence + + + + + Specifies if action is allowed in InstallUISequence + + + + + + + + + + + + diff --git a/src/WixToolset.Core.WindowsInstaller/Data/Xsd/tables.xsd b/src/WixToolset.Core.WindowsInstaller/Data/Xsd/tables.xsd new file mode 100644 index 00000000..f87471bb --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Data/Xsd/tables.xsd @@ -0,0 +1,248 @@ + + + + + + + + Schema for describing table definitions in Windows Installer. + + + + + + + + + + + + + + + + + + + Boolean whether rows in this table create symbols + + + + + Name of table in Windows Installer database + + + + + Specifies if table is virtual or not + + + + + Specifies if the table is a part of the Bootstrapper Application Data manifest + + + + + + + + + + Name of column in Windows Installer table + + + + + + Whether this column was added by a transform. + + + + + + Type of column in Windows Installer table + + + + + + Type of column in Windows Installer table + + + + + + + + + + + + Boolean whether column is primary key of Windows Installer table + + + + + + Boolean whether column is nullable in Windows Installer table + + + + + + Boolean whether column is virtual in Windows Installer table + + + + + + Enumeration specifying how column should have the ModuleId appended + + + + + + Set to "yes" in order to allow substitution for localized variables. + + + + + + Minimum value for column in Windows Installer table + + + + + + Maximum value for column in Windows Installer table + + + + + + Foreign key table for column in Windows Installer table + + + + + + Maximum value for column in Windows Installer table + + + + + + + + + + + + Specific column data types for column + + + + + + List of permissible values for the column + + + + + + Description of column + + + + + + Set to "yes" in order to make the idt exporter escape whitespace characters \r, \n, and \t. + + + + + + Set to "yes" in order to make the Intermediate and Output objects wrap their data in a CDATA element to preserve whitespace. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/WixToolset.Core.WindowsInstaller/Differ.cs b/src/WixToolset.Core.WindowsInstaller/Differ.cs index 9bbde302..7cc204f9 100644 --- a/src/WixToolset.Core.WindowsInstaller/Differ.cs +++ b/src/WixToolset.Core.WindowsInstaller/Differ.cs @@ -10,26 +10,29 @@ namespace WixToolset.Core.WindowsInstaller using WixToolset.Data.WindowsInstaller; using WixToolset.Data.WindowsInstaller.Rows; using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; using WixToolset.Msi; /// /// Creates a transform by diffing two outputs. /// - public sealed class Differ : IMessageHandler + public sealed class Differ { private List inspectorExtensions; private bool showPedanticMessages; private bool suppressKeepingSpecialRows; private bool preserveUnchangedRows; private const char sectionDelimiter = '/'; + private readonly IMessaging messaging; private SummaryInformationStreams transformSummaryInfo; /// /// Instantiates a new Differ class. /// - public Differ() + public Differ(IMessaging messaging) { this.inspectorExtensions = new List(); + this.messaging = messaging; } /// @@ -99,17 +102,17 @@ namespace WixToolset.Core.WindowsInstaller // compare the codepages if (targetOutput.Codepage != updatedOutput.Codepage && 0 == (TransformFlags.ErrorChangeCodePage & validationFlags)) { - this.OnMessage(WixErrors.OutputCodepageMismatch(targetOutput.SourceLineNumbers, targetOutput.Codepage, updatedOutput.Codepage)); + this.messaging.Write(ErrorMessages.OutputCodepageMismatch(targetOutput.SourceLineNumbers, targetOutput.Codepage, updatedOutput.Codepage)); if (null != updatedOutput.SourceLineNumbers) { - this.OnMessage(WixErrors.OutputCodepageMismatch2(updatedOutput.SourceLineNumbers)); + this.messaging.Write(ErrorMessages.OutputCodepageMismatch2(updatedOutput.SourceLineNumbers)); } } // compare the output types if (targetOutput.Type != updatedOutput.Type) { - throw new WixException(WixErrors.OutputTypeMismatch(targetOutput.SourceLineNumbers, targetOutput.Type.ToString(), updatedOutput.Type.ToString())); + throw new WixException(ErrorMessages.OutputTypeMismatch(targetOutput.SourceLineNumbers, targetOutput.Type.ToString(), updatedOutput.Type.ToString())); } // compare the contents of the tables @@ -159,15 +162,6 @@ namespace WixToolset.Core.WindowsInstaller return transform; } - /// - /// Sends a message to the message delegate if there is one. - /// - /// Message event arguments. - public void OnMessage(MessageEventArgs e) - { - Messaging.Instance.OnMessage(e); - } - /// /// Add a row to the using the primary key. /// @@ -210,7 +204,7 @@ namespace WixToolset.Core.WindowsInstaller } else if (this.showPedanticMessages) { - this.OnMessage(WixWarnings.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, row.Table.Name)); + this.messaging.Write(ErrorMessages.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, row.Table.Name)); } } else // use the string representation of the row as its primary key (it may not be unique) @@ -370,7 +364,7 @@ namespace WixToolset.Core.WindowsInstaller if (0 != targetTable.Definition.CompareTo(updatedTable.Definition)) { // continue to the next table; may be more mismatches - this.OnMessage(WixErrors.DatabaseSchemaMismatch(targetOutput.SourceLineNumbers, targetTable.Name)); + this.messaging.Write(ErrorMessages.DatabaseSchemaMismatch(targetOutput.SourceLineNumbers, targetTable.Name)); } else { @@ -425,7 +419,7 @@ namespace WixToolset.Core.WindowsInstaller this.transformSummaryInfo.TargetProductCode = (string)row[1]; if ("*" == this.transformSummaryInfo.TargetProductCode) { - this.OnMessage(WixErrors.ProductCodeInvalidForTransform(row.SourceLineNumbers)); + this.messaging.Write(ErrorMessages.ProductCodeInvalidForTransform(row.SourceLineNumbers)); } } else if ("ProductVersion" == (string)row[0]) @@ -466,7 +460,7 @@ namespace WixToolset.Core.WindowsInstaller this.transformSummaryInfo.UpdatedProductCode = (string)row[1]; if ("*" == this.transformSummaryInfo.UpdatedProductCode) { - this.OnMessage(WixErrors.ProductCodeInvalidForTransform(row.SourceLineNumbers)); + this.messaging.Write(ErrorMessages.ProductCodeInvalidForTransform(row.SourceLineNumbers)); } } else if ("ProductVersion" == (string)row[0]) diff --git a/src/WixToolset.Core.WindowsInstaller/Inscribe/InscribeMsiPackageCommand.cs b/src/WixToolset.Core.WindowsInstaller/Inscribe/InscribeMsiPackageCommand.cs index 5c56d9aa..93dd9d3b 100644 --- a/src/WixToolset.Core.WindowsInstaller/Inscribe/InscribeMsiPackageCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Inscribe/InscribeMsiPackageCommand.cs @@ -36,7 +36,7 @@ namespace WixToolset.Core.WindowsInstaller.Inscribe FileAttributes attributes = File.GetAttributes(this.Context.InputFilePath); if (FileAttributes.ReadOnly == (attributes & FileAttributes.ReadOnly)) { - this.Context.Messaging.OnMessage(WixErrors.ReadOnlyOutputFile(this.Context.InputFilePath)); + this.Context.Messaging.Write(ErrorMessages.ReadOnlyOutputFile(this.Context.InputFilePath)); return shouldCommit; } @@ -179,7 +179,7 @@ namespace WixToolset.Core.WindowsInstaller.Inscribe // If the cabs aren't there, throw an error but continue to catch the other errors if (!File.Exists(cabPath)) { - this.Context.Messaging.OnMessage(WixErrors.WixFileNotFound(cabPath)); + this.Context.Messaging.Write(ErrorMessages.WixFileNotFound(cabPath)); continue; } @@ -205,11 +205,11 @@ namespace WixToolset.Core.WindowsInstaller.Inscribe if ((5 == Environment.OSVersion.Version.Major && 2 == Environment.OSVersion.Version.Minor) || // W2K3 (5 == Environment.OSVersion.Version.Major && 1 == Environment.OSVersion.Version.Minor)) // XP { - this.Context.Messaging.OnMessage(WixErrors.UnableToGetAuthenticodeCertOfFileDownlevelOS(cabPath, String.Format(CultureInfo.InvariantCulture, "HRESULT: 0x{0:x8}", HResult))); + this.Context.Messaging.Write(ErrorMessages.UnableToGetAuthenticodeCertOfFileDownlevelOS(cabPath, String.Format(CultureInfo.InvariantCulture, "HRESULT: 0x{0:x8}", HResult))); } else // otherwise, generic error { - this.Context.Messaging.OnMessage(WixErrors.UnableToGetAuthenticodeCertOfFile(cabPath, String.Format(CultureInfo.InvariantCulture, "HRESULT: 0x{0:x8}", HResult))); + this.Context.Messaging.Write(ErrorMessages.UnableToGetAuthenticodeCertOfFile(cabPath, String.Format(CultureInfo.InvariantCulture, "HRESULT: 0x{0:x8}", HResult))); } } @@ -252,7 +252,7 @@ namespace WixToolset.Core.WindowsInstaller.Inscribe if (digitalCertificateTable.Rows.Count > 0) { - var command = new CreateIdtFileCommand(digitalCertificateTable, codepage, this.Context.IntermediateFolder, true); + var command = new CreateIdtFileCommand(this.Context.Messaging, digitalCertificateTable, codepage, this.Context.IntermediateFolder, true); command.Execute(); database.Import(command.IdtPath); @@ -261,7 +261,7 @@ namespace WixToolset.Core.WindowsInstaller.Inscribe if (digitalSignatureTable.Rows.Count > 0) { - var command = new CreateIdtFileCommand(digitalSignatureTable, codepage, this.Context.IntermediateFolder, true); + var command = new CreateIdtFileCommand(this.Context.Messaging, digitalSignatureTable, codepage, this.Context.IntermediateFolder, true); command.Execute(); database.Import(command.IdtPath); @@ -275,7 +275,7 @@ namespace WixToolset.Core.WindowsInstaller.Inscribe // If we did find external cabs but none of them were signed, give a warning if (foundUnsignedExternals) { - this.Context.Messaging.OnMessage(WixWarnings.ExternalCabsAreNotSigned(this.Context.InputFilePath)); + this.Context.Messaging.Write(WarningMessages.ExternalCabsAreNotSigned(this.Context.InputFilePath)); } if (shouldCommit) diff --git a/src/WixToolset.Core.WindowsInstaller/MelterCore.cs b/src/WixToolset.Core.WindowsInstaller/MelterCore.cs index 75d43619..034c9465 100644 --- a/src/WixToolset.Core.WindowsInstaller/MelterCore.cs +++ b/src/WixToolset.Core.WindowsInstaller/MelterCore.cs @@ -7,8 +7,9 @@ namespace WixToolset /// /// Melts a Module Wix document into a ComponentGroup representation. /// - public sealed class MelterCore : IMessageHandler + public sealed class MelterCore { +#if TODO_MELT /// /// Gets whether the melter core encountered an error while processing. /// @@ -26,5 +27,6 @@ namespace WixToolset { Messaging.Instance.OnMessage(e); } +#endif } } diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/WixInvalidIdtException.cs b/src/WixToolset.Core.WindowsInstaller/Msi/WixInvalidIdtException.cs index a603d5a7..589da648 100644 --- a/src/WixToolset.Core.WindowsInstaller/Msi/WixInvalidIdtException.cs +++ b/src/WixToolset.Core.WindowsInstaller/Msi/WixInvalidIdtException.cs @@ -16,7 +16,7 @@ namespace WixToolset.Msi /// /// The invalid idt file. public WixInvalidIdtException(string idtFile) : - base(WixDataErrors.InvalidIdt(new SourceLineNumber(idtFile), idtFile)) + base(ErrorMessages.InvalidIdt(new SourceLineNumber(idtFile), idtFile)) { } @@ -26,7 +26,7 @@ namespace WixToolset.Msi /// The invalid idt file. /// The table name of the invalid idt file. public WixInvalidIdtException(string idtFile, string tableName) : - base(WixDataErrors.InvalidIdt(new SourceLineNumber(idtFile), idtFile, tableName)) + base(ErrorMessages.InvalidIdt(new SourceLineNumber(idtFile), idtFile, tableName)) { } } diff --git a/src/WixToolset.Core.WindowsInstaller/Patch.cs b/src/WixToolset.Core.WindowsInstaller/Patch.cs index 24a54859..c1914aca 100644 --- a/src/WixToolset.Core.WindowsInstaller/Patch.cs +++ b/src/WixToolset.Core.WindowsInstaller/Patch.cs @@ -1232,14 +1232,5 @@ namespace WixToolset.Data #endif throw new NotImplementedException(); } - - /// - /// Sends a message to the message delegate if there is one. - /// - /// Message event arguments. - public void OnMessage(MessageEventArgs mea) - { - Messaging.Instance.OnMessage(mea); - } } } diff --git a/src/WixToolset.Core.WindowsInstaller/PatchTransform.cs b/src/WixToolset.Core.WindowsInstaller/PatchTransform.cs index 9ba14843..0dc1e874 100644 --- a/src/WixToolset.Core.WindowsInstaller/PatchTransform.cs +++ b/src/WixToolset.Core.WindowsInstaller/PatchTransform.cs @@ -10,7 +10,7 @@ namespace WixToolset using WixToolset.Data; using WixToolset.Extensibility; - public class PatchTransform : IMessageHandler + public class PatchTransform { private string baseline; private Intermediate transform; @@ -264,14 +264,5 @@ namespace WixToolset #endif throw new NotImplementedException(); } - - /// - /// Sends a message to the message delegate if there is one. - /// - /// Message event arguments. - public void OnMessage(MessageEventArgs e) - { - Messaging.Instance.OnMessage(e); - } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Unbind/ExtractCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Unbind/ExtractCabinetsCommand.cs index 1757e06f..ed3161ef 100644 --- a/src/WixToolset.Core.WindowsInstaller/Unbind/ExtractCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Unbind/ExtractCabinetsCommand.cs @@ -136,7 +136,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind } catch (FileNotFoundException) { - throw new WixException(WixErrors.FileNotFound(new SourceLineNumber(this.InputFilePath), cabinetFile)); + throw new WixException(ErrorMessages.FileNotFound(new SourceLineNumber(this.InputFilePath), cabinetFile)); } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs index 72e0c3c8..5d24d08a 100644 --- a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs @@ -12,11 +12,12 @@ namespace WixToolset.Core.WindowsInstaller.Unbind using WixToolset.Data; using WixToolset.Data.WindowsInstaller; using WixToolset.Data.WindowsInstaller.Rows; + using WixToolset.Extensibility.Services; using WixToolset.Msi; internal class UnbindDatabaseCommand { - public UnbindDatabaseCommand(Messaging messaging, Database database, string databasePath, OutputType outputType, string exportBasePath, string intermediateFolder, bool isAdminImage, bool suppressDemodularization, bool skipSummaryInfo) + public UnbindDatabaseCommand(IMessaging messaging, Database database, string databasePath, OutputType outputType, string exportBasePath, string intermediateFolder, bool isAdminImage, bool suppressDemodularization, bool skipSummaryInfo) { this.Messaging = messaging; this.Database = database; @@ -31,7 +32,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions(); } - public Messaging Messaging { get; } + public IMessaging Messaging { get; } public Database Database { get; } @@ -316,7 +317,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind if (!success) { - this.Messaging.OnMessage(WixWarnings.BadColumnDataIgnored(row.SourceLineNumbers, Convert.ToString(intValue, CultureInfo.InvariantCulture), tableName, row.Fields[i].Column.Name)); + this.Messaging.Write(WarningMessages.BadColumnDataIgnored(row.SourceLineNumbers, Convert.ToString(intValue, CultureInfo.InvariantCulture), tableName, row.Fields[i].Column.Name)); } break; case ColumnType.Object: @@ -480,7 +481,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind if (!File.Exists(wixFileRow.Source)) { - throw new WixException(WixErrors.WixFileNotFound(wixFileRow.Source)); + throw new WixException(ErrorMessages.WixFileNotFound(wixFileRow.Source)); } wixFileTable.Rows.Add(wixFileRow); diff --git a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindTranformCommand.cs b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindTranformCommand.cs index 70f751f5..2b018013 100644 --- a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindTranformCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindTranformCommand.cs @@ -13,11 +13,12 @@ namespace WixToolset.Core.WindowsInstaller.Unbind using WixToolset.Data; using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; using WixToolset.Msi; internal class UnbindTransformCommand { - public UnbindTransformCommand(Messaging messaging, string transformFile, string exportBasePath, string intermediateFolder) + public UnbindTransformCommand(IMessaging messaging, string transformFile, string exportBasePath, string intermediateFolder) { this.Messaging = messaging; this.TransformFile = transformFile; @@ -27,7 +28,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions(); } - private Messaging Messaging { get; } + private IMessaging Messaging { get; } private string TransformFile { get; } @@ -152,7 +153,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind // this commonly happens when the transform was built // against a database schema different from the internal // table definitions - throw new WixException(WixErrors.TransformSchemaMismatch()); + throw new WixException(ErrorMessages.TransformSchemaMismatch()); } } diff --git a/src/WixToolset.Core.WindowsInstaller/UnbindContext.cs b/src/WixToolset.Core.WindowsInstaller/UnbindContext.cs index ed55f312..ff71bea4 100644 --- a/src/WixToolset.Core.WindowsInstaller/UnbindContext.cs +++ b/src/WixToolset.Core.WindowsInstaller/UnbindContext.cs @@ -2,12 +2,15 @@ namespace WixToolset.Core { - using WixToolset.Data; + using System; using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; internal class UnbindContext : IUnbindContext { - public Messaging Messaging { get; } = Messaging.Instance; + public IServiceProvider ServiceProvider { get; } + + public IMessaging Messaging { get; set; } public string ExportBasePath { get; set; } diff --git a/src/WixToolset.Core.WindowsInstaller/Unbinder.cs b/src/WixToolset.Core.WindowsInstaller/Unbinder.cs index d2d27d45..db121fc0 100644 --- a/src/WixToolset.Core.WindowsInstaller/Unbinder.cs +++ b/src/WixToolset.Core.WindowsInstaller/Unbinder.cs @@ -53,11 +53,11 @@ namespace WixToolset.Core { if (OutputType.Transform == outputType) { - throw new WixException(WixErrors.FileNotFound(null, file, "Transform")); + throw new WixException(ErrorMessages.FileNotFound(null, file, "Transform")); } else { - throw new WixException(WixErrors.FileNotFound(null, file, "Database")); + throw new WixException(ErrorMessages.FileNotFound(null, file, "Database")); } } diff --git a/src/WixToolset.Core.WindowsInstaller/Validator.cs b/src/WixToolset.Core.WindowsInstaller/Validator.cs index eb17d8af..d553cc71 100644 --- a/src/WixToolset.Core.WindowsInstaller/Validator.cs +++ b/src/WixToolset.Core.WindowsInstaller/Validator.cs @@ -22,7 +22,7 @@ namespace WixToolset.Core.WindowsInstaller /// /// Runs internal consistency evaluators (ICEs) from cub files against a database. /// - public sealed class Validator : IMessageHandler + public sealed class Validator { private string actionName; private StringCollection cubeFiles; @@ -30,15 +30,17 @@ namespace WixToolset.Core.WindowsInstaller private Output output; private InstallUIHandler validationUIHandler; private bool validationSessionComplete; + private readonly IMessaging messaging; /// /// Instantiate a new Validator. /// - public Validator() + public Validator(IMessaging messaging) { this.cubeFiles = new StringCollection(); - this.extension = new ValidatorExtension(); + this.extension = new ValidatorExtension(messaging); this.validationUIHandler = new InstallUIHandler(this.ValidationUIHandler); + this.messaging = messaging; } /// @@ -127,7 +129,7 @@ namespace WixToolset.Core.WindowsInstaller { if (!mutex.WaitOne(0, false)) { - this.OnMessage(WixVerboses.ValidationSerialized()); + this.messaging.Write(VerboseMessages.ValidationSerialized()); mutex.WaitOne(); } @@ -176,7 +178,7 @@ namespace WixToolset.Core.WindowsInstaller { if (0x6E == e.NativeErrorCode) // ERROR_OPEN_FAILED { - throw new WixException(WixErrors.CubeFileNotFound(cubeFile)); + throw new WixException(ErrorMessages.CubeFileNotFound(cubeFile)); } throw; @@ -248,7 +250,7 @@ namespace WixToolset.Core.WindowsInstaller } catch (Win32Exception e) { - if (!Messaging.Instance.EncounteredError) + if (!this.messaging.EncounteredError) { throw e; } @@ -270,7 +272,7 @@ namespace WixToolset.Core.WindowsInstaller catch (Win32Exception e) { // avoid displaying errors twice since one may have already occurred in the UI handler - if (!Messaging.Instance.EncounteredError) + if (!this.messaging.EncounteredError) { if (0x6E == e.NativeErrorCode) // ERROR_OPEN_FAILED { @@ -278,23 +280,23 @@ namespace WixToolset.Core.WindowsInstaller // this would be the temporary copy and there would be // no final output since the error occured; during smoke // they should know the path passed into smoke - this.OnMessage(WixErrors.ValidationFailedToOpenDatabase()); + this.messaging.Write(ErrorMessages.ValidationFailedToOpenDatabase()); } else if (0x64D == e.NativeErrorCode) { - this.OnMessage(WixErrors.ValidationFailedDueToLowMsiEngine()); + this.messaging.Write(ErrorMessages.ValidationFailedDueToLowMsiEngine()); } else if (0x654 == e.NativeErrorCode) { - this.OnMessage(WixErrors.ValidationFailedDueToInvalidPackage()); + this.messaging.Write(ErrorMessages.ValidationFailedDueToInvalidPackage()); } else if (0x658 == e.NativeErrorCode) { - this.OnMessage(WixErrors.ValidationFailedDueToMultilanguageMergeModule()); + this.messaging.Write(ErrorMessages.ValidationFailedDueToMultilanguageMergeModule()); } else if (0x659 == e.NativeErrorCode) { - this.OnMessage(WixWarnings.ValidationFailedDueToSystemPolicy()); + this.messaging.Write(WarningMessages.ValidationFailedDueToSystemPolicy()); } else { @@ -305,7 +307,7 @@ namespace WixToolset.Core.WindowsInstaller msgTemp = String.Concat("Action - '", this.actionName, "' ", e.Message); } - this.OnMessage(WixErrors.Win32Exception(e.NativeErrorCode, msgTemp)); + this.messaging.Write(ErrorMessages.Win32Exception(e.NativeErrorCode, msgTemp)); } } } @@ -322,16 +324,6 @@ namespace WixToolset.Core.WindowsInstaller } } - /// - /// Sends a message to the message delegate if there is one. - /// - /// Message event arguments. - public void OnMessage(MessageEventArgs e) - { - Messaging.Instance.OnMessage(e); - this.extension.OnMessage(e); - } - public static Validator CreateFromContext(IBindContext context, string cubeFilename) { Validator validator = null; @@ -339,7 +331,7 @@ namespace WixToolset.Core.WindowsInstaller // Tell the binder about the validator if validation isn't suppressed if (!context.SuppressValidation) { - validator = new Validator(); + validator = new Validator(context.Messaging); validator.IntermediateFolder = Path.Combine(context.IntermediateFolder, "validate"); // set the default cube file @@ -378,7 +370,7 @@ namespace WixToolset.Core.WindowsInstaller } catch (WixException ex) { - this.OnMessage(ex.Error); + this.messaging.Write(ex.Error); } return 1; diff --git a/src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs b/src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs index 67f5962c..48f73bf2 100644 --- a/src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs +++ b/src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs @@ -6,23 +6,26 @@ namespace WixToolset.Extensibility using System.Collections; using WixToolset.Data; using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility.Services; /// /// Base class for creating a validator extension. This default implementation /// will fire and event with the ICE name and description. /// - public class ValidatorExtension : IMessageHandler + public class ValidatorExtension { private string databaseFile; private Hashtable indexedSourceLineNumbers; private Output output; private SourceLineNumber sourceLineNumbers; + private readonly IMessaging messaging; /// /// Instantiate a new . /// - public ValidatorExtension() + public ValidatorExtension(IMessaging messaging) { + this.messaging = messaging; } /// @@ -183,11 +186,11 @@ namespace WixToolset.Extensibility { if (null == action) { - throw new WixException(WixErrors.UnexpectedExternalUIMessage(message)); + throw new WixException(ErrorMessages.UnexpectedExternalUIMessage(message)); } else { - throw new WixException(WixErrors.UnexpectedExternalUIMessage(message, action)); + throw new WixException(ErrorMessages.UnexpectedExternalUIMessage(message, action)); } } @@ -209,16 +212,16 @@ namespace WixToolset.Extensibility { case "0": case "1": - this.OnMessage(WixErrors.ValidationError(messageSourceLineNumbers, messageParts[0], messageParts[2])); + this.messaging.Write(ErrorMessages.ValidationError(messageSourceLineNumbers, messageParts[0], messageParts[2])); break; case "2": - this.OnMessage(WixWarnings.ValidationWarning(messageSourceLineNumbers, messageParts[0], messageParts[2])); + this.messaging.Write(WarningMessages.ValidationWarning(messageSourceLineNumbers, messageParts[0], messageParts[2])); break; case "3": - this.OnMessage(WixVerboses.ValidationInfo(messageParts[0], messageParts[2])); + this.messaging.Write(VerboseMessages.ValidationInfo(messageParts[0], messageParts[2])); break; default: - throw new WixException(WixErrors.InvalidValidatorMessageType(messageParts[1])); + throw new WixException(ErrorMessages.InvalidValidatorMessageType(messageParts[1])); } } @@ -264,7 +267,7 @@ namespace WixToolset.Extensibility if (this.indexedSourceLineNumbers.ContainsKey(key)) { - this.OnMessage(WixWarnings.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, table.Name)); + this.messaging.Write(WarningMessages.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, table.Name)); } else { @@ -281,20 +284,5 @@ namespace WixToolset.Extensibility // use the file name as the source line information return this.sourceLineNumbers; } - - /// - /// Sends a message to the delegate if there is one. - /// - /// Message event arguments. - /// - /// Notes to Inheritors: When overriding OnMessage - /// in a derived class, be sure to call the base class's - /// OnMessage method so that registered delegates recieve - /// the event. - /// - public virtual void OnMessage(MessageEventArgs e) - { - Messaging.Instance.OnMessage(e); - } } } diff --git a/src/WixToolset.Core.WindowsInstaller/WindowsInstallerStandardInternal.cs b/src/WixToolset.Core.WindowsInstaller/WindowsInstallerStandardInternal.cs index 3b4721a6..759bda14 100644 --- a/src/WixToolset.Core.WindowsInstaller/WindowsInstallerStandardInternal.cs +++ b/src/WixToolset.Core.WindowsInstaller/WindowsInstallerStandardInternal.cs @@ -16,7 +16,9 @@ namespace WixToolset.Core.WindowsInstaller private static readonly object lockObject = new object(); private static TableDefinitionCollection tableDefinitions; +#if REVISIT_FOR_PATCHING private static WixActionRowCollection standardActions; +#endif /// /// Gets the table definitions stored in this assembly. @@ -57,7 +59,7 @@ namespace WixToolset.Core.WindowsInstaller } return WindowsInstallerStandardInternal.standardActions; -#endif +#endif throw new NotImplementedException(); } } -- cgit v1.2.3-55-g6feb