diff options
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs')
-rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs | 46 |
1 files changed, 25 insertions, 21 deletions
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 | |||
15 | using WixToolset.Data; | 15 | using WixToolset.Data; |
16 | using WixToolset.Data.Tuples; | 16 | using WixToolset.Data.Tuples; |
17 | using WixToolset.Data.WindowsInstaller; | 17 | using WixToolset.Data.WindowsInstaller; |
18 | using WixToolset.Extensibility.Services; | ||
18 | using WixToolset.Msi; | 19 | using WixToolset.Msi; |
19 | 20 | ||
20 | /// <summary> | 21 | /// <summary> |
@@ -22,11 +23,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
22 | /// </summary> | 23 | /// </summary> |
23 | internal class UpdateFileFacadesCommand | 24 | internal class UpdateFileFacadesCommand |
24 | { | 25 | { |
25 | public UpdateFileFacadesCommand(IntermediateSection section) | 26 | public UpdateFileFacadesCommand(IMessaging messaging, IntermediateSection section) |
26 | { | 27 | { |
28 | this.Messaging = messaging; | ||
27 | this.Section = section; | 29 | this.Section = section; |
28 | } | 30 | } |
29 | 31 | ||
32 | private IMessaging Messaging { get; } | ||
33 | |||
30 | private IntermediateSection Section { get; } | 34 | private IntermediateSection Section { get; } |
31 | 35 | ||
32 | public IEnumerable<FileFacade> FileFacades { private get; set; } | 36 | public IEnumerable<FileFacade> FileFacades { private get; set; } |
@@ -62,23 +66,23 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
62 | } | 66 | } |
63 | catch (ArgumentException) | 67 | catch (ArgumentException) |
64 | { | 68 | { |
65 | Messaging.Instance.OnMessage(WixDataErrors.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); | 69 | this.Messaging.Write(ErrorMessages.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); |
66 | return; | 70 | return; |
67 | } | 71 | } |
68 | catch (PathTooLongException) | 72 | catch (PathTooLongException) |
69 | { | 73 | { |
70 | Messaging.Instance.OnMessage(WixDataErrors.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); | 74 | this.Messaging.Write(ErrorMessages.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); |
71 | return; | 75 | return; |
72 | } | 76 | } |
73 | catch (NotSupportedException) | 77 | catch (NotSupportedException) |
74 | { | 78 | { |
75 | Messaging.Instance.OnMessage(WixDataErrors.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); | 79 | this.Messaging.Write(ErrorMessages.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); |
76 | return; | 80 | return; |
77 | } | 81 | } |
78 | 82 | ||
79 | if (!fileInfo.Exists) | 83 | if (!fileInfo.Exists) |
80 | { | 84 | { |
81 | Messaging.Instance.OnMessage(WixErrors.CannotFindFile(file.File.SourceLineNumbers, file.File.File, file.File.LongFileName, file.WixFile.Source.Path)); | 85 | this.Messaging.Write(ErrorMessages.CannotFindFile(file.File.SourceLineNumbers, file.File.File, file.File.LongFileName, file.WixFile.Source.Path)); |
82 | return; | 86 | return; |
83 | } | 87 | } |
84 | 88 | ||
@@ -86,7 +90,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
86 | { | 90 | { |
87 | if (Int32.MaxValue < fileStream.Length) | 91 | if (Int32.MaxValue < fileStream.Length) |
88 | { | 92 | { |
89 | throw new WixException(WixErrors.FileTooLarge(file.File.SourceLineNumbers, file.WixFile.Source.Path)); | 93 | throw new WixException(ErrorMessages.FileTooLarge(file.File.SourceLineNumbers, file.WixFile.Source.Path)); |
90 | } | 94 | } |
91 | 95 | ||
92 | file.File.FileSize = Convert.ToInt32(fileStream.Length, CultureInfo.InvariantCulture); | 96 | file.File.FileSize = Convert.ToInt32(fileStream.Length, CultureInfo.InvariantCulture); |
@@ -102,11 +106,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
102 | { | 106 | { |
103 | if (0x2 == e.NativeErrorCode) // ERROR_FILE_NOT_FOUND | 107 | if (0x2 == e.NativeErrorCode) // ERROR_FILE_NOT_FOUND |
104 | { | 108 | { |
105 | throw new WixException(WixErrors.FileNotFound(file.File.SourceLineNumbers, fileInfo.FullName)); | 109 | throw new WixException(ErrorMessages.FileNotFound(file.File.SourceLineNumbers, fileInfo.FullName)); |
106 | } | 110 | } |
107 | else | 111 | else |
108 | { | 112 | { |
109 | throw new WixException(WixErrors.Win32Exception(e.NativeErrorCode, e.Message)); | 113 | throw new WixException(ErrorMessages.Win32Exception(e.NativeErrorCode, e.Message)); |
110 | } | 114 | } |
111 | } | 115 | } |
112 | 116 | ||
@@ -128,14 +132,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
128 | // for unversioned file. That's allowed but generally a dangerous thing to do so let's point that out to the user. | 132 | // for unversioned file. That's allowed but generally a dangerous thing to do so let's point that out to the user. |
129 | if (!this.FileFacades.Any(r => file.File.Version.Equals(r.File.File, StringComparison.Ordinal))) | 133 | if (!this.FileFacades.Any(r => file.File.Version.Equals(r.File.File, StringComparison.Ordinal))) |
130 | { | 134 | { |
131 | Messaging.Instance.OnMessage(WixWarnings.DefaultVersionUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Version, file.File.File)); | 135 | this.Messaging.Write(WarningMessages.DefaultVersionUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Version, file.File.File)); |
132 | } | 136 | } |
133 | } | 137 | } |
134 | else | 138 | else |
135 | { | 139 | { |
136 | if (null != file.File.Language) | 140 | if (null != file.File.Language) |
137 | { | 141 | { |
138 | Messaging.Instance.OnMessage(WixWarnings.DefaultLanguageUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.File)); | 142 | this.Messaging.Write(WarningMessages.DefaultLanguageUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.File)); |
139 | } | 143 | } |
140 | 144 | ||
141 | int[] hash; | 145 | int[] hash; |
@@ -147,11 +151,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
147 | { | 151 | { |
148 | if (0x2 == e.NativeErrorCode) // ERROR_FILE_NOT_FOUND | 152 | if (0x2 == e.NativeErrorCode) // ERROR_FILE_NOT_FOUND |
149 | { | 153 | { |
150 | throw new WixException(WixErrors.FileNotFound(file.File.SourceLineNumbers, fileInfo.FullName)); | 154 | throw new WixException(ErrorMessages.FileNotFound(file.File.SourceLineNumbers, fileInfo.FullName)); |
151 | } | 155 | } |
152 | else | 156 | else |
153 | { | 157 | { |
154 | throw new WixException(WixErrors.Win32Exception(e.NativeErrorCode, fileInfo.FullName, e.Message)); | 158 | throw new WixException(ErrorMessages.Win32Exception(e.NativeErrorCode, fileInfo.FullName, e.Message)); |
155 | } | 159 | } |
156 | } | 160 | } |
157 | 161 | ||
@@ -193,7 +197,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
193 | 197 | ||
194 | if (!String.IsNullOrEmpty(file.File.Language) && String.IsNullOrEmpty(language)) | 198 | if (!String.IsNullOrEmpty(file.File.Language) && String.IsNullOrEmpty(language)) |
195 | { | 199 | { |
196 | Messaging.Instance.OnMessage(WixWarnings.DefaultLanguageUsedForVersionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.File)); | 200 | this.Messaging.Write(WarningMessages.DefaultLanguageUsedForVersionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.File)); |
197 | } | 201 | } |
198 | else // override the default provided by the user (usually nothing) with the actual language from the file itself. | 202 | else // override the default provided by the user (usually nothing) with the actual language from the file itself. |
199 | { | 203 | { |
@@ -260,7 +264,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
260 | } | 264 | } |
261 | else if (file.WixFile.File_AssemblyApplication == null) | 265 | else if (file.WixFile.File_AssemblyApplication == null) |
262 | { | 266 | { |
263 | throw new WixException(WixErrors.GacAssemblyNoStrongName(file.File.SourceLineNumbers, fileInfo.FullName, file.File.Component_)); | 267 | throw new WixException(ErrorMessages.GacAssemblyNoStrongName(file.File.SourceLineNumbers, fileInfo.FullName, file.File.Component_)); |
264 | } | 268 | } |
265 | 269 | ||
266 | string assemblyVersion = referenceIdentity.GetAttribute(null, "Version"); | 270 | string assemblyVersion = referenceIdentity.GetAttribute(null, "Version"); |
@@ -271,7 +275,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
271 | } | 275 | } |
272 | else | 276 | else |
273 | { | 277 | { |
274 | Messaging.Instance.OnMessage(WixErrors.InvalidAssemblyFile(file.File.SourceLineNumbers, fileInfo.FullName, String.Format(CultureInfo.InvariantCulture, "HRESULT: 0x{0:x8}", result))); | 278 | this.Messaging.Write(ErrorMessages.InvalidAssemblyFile(file.File.SourceLineNumbers, fileInfo.FullName, String.Format(CultureInfo.InvariantCulture, "HRESULT: 0x{0:x8}", result))); |
275 | return; | 279 | return; |
276 | } | 280 | } |
277 | 281 | ||
@@ -360,7 +364,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
360 | FileFacade fileManifest = this.FileFacades.SingleOrDefault(r => r.File.File.Equals(file.WixFile.File_AssemblyManifest, StringComparison.Ordinal)); | 364 | FileFacade fileManifest = this.FileFacades.SingleOrDefault(r => r.File.File.Equals(file.WixFile.File_AssemblyManifest, StringComparison.Ordinal)); |
361 | if (null == fileManifest) | 365 | if (null == fileManifest) |
362 | { | 366 | { |
363 | Messaging.Instance.OnMessage(WixErrors.MissingManifestForWin32Assembly(file.File.SourceLineNumbers, file.File.File, file.WixFile.File_AssemblyManifest)); | 367 | this.Messaging.Write(ErrorMessages.MissingManifestForWin32Assembly(file.File.SourceLineNumbers, file.File.File, file.WixFile.File_AssemblyManifest)); |
364 | } | 368 | } |
365 | 369 | ||
366 | string win32Type = null; | 370 | string win32Type = null; |
@@ -397,7 +401,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
397 | } | 401 | } |
398 | if (!hasNextSibling) | 402 | if (!hasNextSibling) |
399 | { | 403 | { |
400 | Messaging.Instance.OnMessage(WixErrors.InvalidManifestContent(file.File.SourceLineNumbers, fileManifest.WixFile.Source.Path)); | 404 | this.Messaging.Write(ErrorMessages.InvalidManifestContent(file.File.SourceLineNumbers, fileManifest.WixFile.Source.Path)); |
401 | return; | 405 | return; |
402 | } | 406 | } |
403 | 407 | ||
@@ -435,11 +439,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
435 | } | 439 | } |
436 | catch (FileNotFoundException fe) | 440 | catch (FileNotFoundException fe) |
437 | { | 441 | { |
438 | Messaging.Instance.OnMessage(WixErrors.FileNotFound(new SourceLineNumber(fileManifest.WixFile.Source.Path), fe.FileName, "AssemblyManifest")); | 442 | this.Messaging.Write(ErrorMessages.FileNotFound(new SourceLineNumber(fileManifest.WixFile.Source.Path), fe.FileName, "AssemblyManifest")); |
439 | } | 443 | } |
440 | catch (XmlException xe) | 444 | catch (XmlException xe) |
441 | { | 445 | { |
442 | Messaging.Instance.OnMessage(WixErrors.InvalidXml(new SourceLineNumber(fileManifest.WixFile.Source.Path), "manifest", xe.Message)); | 446 | this.Messaging.Write(ErrorMessages.InvalidXml(new SourceLineNumber(fileManifest.WixFile.Source.Path), "manifest", xe.Message)); |
443 | } | 447 | } |
444 | 448 | ||
445 | if (!String.IsNullOrEmpty(win32Name)) | 449 | if (!String.IsNullOrEmpty(win32Name)) |
@@ -482,7 +486,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
482 | // check for null value (this can occur when grabbing the file version from an assembly without one) | 486 | // check for null value (this can occur when grabbing the file version from an assembly without one) |
483 | if (String.IsNullOrEmpty(value)) | 487 | if (String.IsNullOrEmpty(value)) |
484 | { | 488 | { |
485 | Messaging.Instance.OnMessage(WixWarnings.NullMsiAssemblyNameValue(file.File.SourceLineNumbers, file.File.Component_, name)); | 489 | this.Messaging.Write(WarningMessages.NullMsiAssemblyNameValue(file.File.SourceLineNumbers, file.File.Component_, name)); |
486 | } | 490 | } |
487 | else | 491 | else |
488 | { | 492 | { |
@@ -491,7 +495,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
491 | String.IsNullOrEmpty(file.WixFile.File_AssemblyApplication) && | 495 | String.IsNullOrEmpty(file.WixFile.File_AssemblyApplication) && |
492 | !String.Equals(Path.GetFileNameWithoutExtension(file.File.LongFileName), value, StringComparison.OrdinalIgnoreCase)) | 496 | !String.Equals(Path.GetFileNameWithoutExtension(file.File.LongFileName), value, StringComparison.OrdinalIgnoreCase)) |
493 | { | 497 | { |
494 | Messaging.Instance.OnMessage(WixErrors.GACAssemblyIdentityWarning(file.File.SourceLineNumbers, Path.GetFileNameWithoutExtension(file.File.LongFileName), value)); | 498 | this.Messaging.Write(ErrorMessages.GACAssemblyIdentityWarning(file.File.SourceLineNumbers, Path.GetFileNameWithoutExtension(file.File.LongFileName), value)); |
495 | } | 499 | } |
496 | 500 | ||
497 | // override directly authored value | 501 | // override directly authored value |