diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-12-19 12:25:40 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-12-19 12:25:40 -0800 |
| commit | 155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 (patch) | |
| tree | 59d1f151bfde8068b6014b05b5c8cfea3402c974 /src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | |
| parent | 6f1665ed759b31bd095f186f9239232c653597cd (diff) | |
| download | wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.gz wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.bz2 wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.zip | |
Integrate simplified message handling
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | 41 |
1 files changed, 22 insertions, 19 deletions
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 | |||
| 16 | using WixToolset.Data.WindowsInstaller; | 16 | using WixToolset.Data.WindowsInstaller; |
| 17 | using WixToolset.Data.WindowsInstaller.Rows; | 17 | using WixToolset.Data.WindowsInstaller.Rows; |
| 18 | using WixToolset.Extensibility; | 18 | using WixToolset.Extensibility; |
| 19 | using WixToolset.Extensibility.Services; | ||
| 19 | 20 | ||
| 20 | /// <summary> | 21 | /// <summary> |
| 21 | /// Creates cabinet files. | 22 | /// Creates cabinet files. |
| @@ -45,6 +46,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 45 | 46 | ||
| 46 | public string CabCachePath { private get; set; } | 47 | public string CabCachePath { private get; set; } |
| 47 | 48 | ||
| 49 | public IMessaging Messaging { private get; set; } | ||
| 50 | |||
| 48 | public string TempFilesLocation { private get; set; } | 51 | public string TempFilesLocation { private get; set; } |
| 49 | 52 | ||
| 50 | /// <summary> | 53 | /// <summary> |
| @@ -85,7 +88,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 85 | this.SetCabbingThreadCount(); | 88 | this.SetCabbingThreadCount(); |
| 86 | 89 | ||
| 87 | // Send Binder object to Facilitate NewCabNamesCallBack Callback | 90 | // Send Binder object to Facilitate NewCabNamesCallBack Callback |
| 88 | CabinetBuilder cabinetBuilder = new CabinetBuilder(this.CabbingThreadCount, Marshal.GetFunctionPointerForDelegate(this.newCabNamesCallBack)); | 91 | CabinetBuilder cabinetBuilder = new CabinetBuilder(this.Messaging, this.CabbingThreadCount, Marshal.GetFunctionPointerForDelegate(this.newCabNamesCallBack)); |
| 89 | 92 | ||
| 90 | // Supply Compile MediaTemplate Attributes to Cabinet Builder | 93 | // Supply Compile MediaTemplate Attributes to Cabinet Builder |
| 91 | this.GetMediaTemplateAttributes(out var MaximumCabinetSizeForLargeFileSplitting, out var MaximumUncompressedMediaSize); | 94 | this.GetMediaTemplateAttributes(out var MaximumCabinetSizeForLargeFileSplitting, out var MaximumUncompressedMediaSize); |
| @@ -120,14 +123,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 120 | } | 123 | } |
| 121 | 124 | ||
| 122 | // stop processing if an error previously occurred | 125 | // stop processing if an error previously occurred |
| 123 | if (Messaging.Instance.EncounteredError) | 126 | if (this.Messaging.EncounteredError) |
| 124 | { | 127 | { |
| 125 | return; | 128 | return; |
| 126 | } | 129 | } |
| 127 | 130 | ||
| 128 | // create queued cabinets with multiple threads | 131 | // create queued cabinets with multiple threads |
| 129 | cabinetBuilder.CreateQueuedCabinets(); | 132 | cabinetBuilder.CreateQueuedCabinets(); |
| 130 | if (Messaging.Instance.EncounteredError) | 133 | if (this.Messaging.EncounteredError) |
| 131 | { | 134 | { |
| 132 | return; | 135 | return; |
| 133 | } | 136 | } |
| @@ -152,7 +155,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 152 | 155 | ||
| 153 | if (0 >= this.CabbingThreadCount) | 156 | if (0 >= this.CabbingThreadCount) |
| 154 | { | 157 | { |
| 155 | throw new WixException(WixErrors.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | 158 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); |
| 156 | } | 159 | } |
| 157 | } | 160 | } |
| 158 | else // default to 1 if the environment variable is not set | 161 | else // default to 1 if the environment variable is not set |
| @@ -160,15 +163,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 160 | this.CabbingThreadCount = 1; | 163 | this.CabbingThreadCount = 1; |
| 161 | } | 164 | } |
| 162 | 165 | ||
| 163 | Messaging.Instance.OnMessage(WixVerboses.SetCabbingThreadCount(this.CabbingThreadCount.ToString())); | 166 | this.Messaging.Write(VerboseMessages.SetCabbingThreadCount(this.CabbingThreadCount.ToString())); |
| 164 | } | 167 | } |
| 165 | catch (ArgumentException) | 168 | catch (ArgumentException) |
| 166 | { | 169 | { |
| 167 | throw new WixException(WixErrors.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | 170 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); |
| 168 | } | 171 | } |
| 169 | catch (FormatException) | 172 | catch (FormatException) |
| 170 | { | 173 | { |
| 171 | throw new WixException(WixErrors.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | 174 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); |
| 172 | } | 175 | } |
| 173 | } | 176 | } |
| 174 | } | 177 | } |
| @@ -202,11 +205,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 202 | // If building a patch, remind them to run -p for torch. | 205 | // If building a patch, remind them to run -p for torch. |
| 203 | if (OutputType.Patch == output.Type) | 206 | if (OutputType.Patch == output.Type) |
| 204 | { | 207 | { |
| 205 | Messaging.Instance.OnMessage(WixWarnings.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName, true)); | 208 | this.Messaging.Write(WarningMessages.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName, true)); |
| 206 | } | 209 | } |
| 207 | else | 210 | else |
| 208 | { | 211 | { |
| 209 | Messaging.Instance.OnMessage(WixWarnings.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName)); | 212 | this.Messaging.Write(WarningMessages.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName)); |
| 210 | } | 213 | } |
| 211 | } | 214 | } |
| 212 | 215 | ||
| @@ -223,7 +226,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 223 | } | 226 | } |
| 224 | else // reuse the cabinet from the cabinet cache. | 227 | else // reuse the cabinet from the cabinet cache. |
| 225 | { | 228 | { |
| 226 | Messaging.Instance.OnMessage(WixVerboses.ReusingCabCache(mediaRow.SourceLineNumbers, mediaRow.Cabinet, resolvedCabinet.Path)); | 229 | this.Messaging.Write(VerboseMessages.ReusingCabCache(mediaRow.SourceLineNumbers, mediaRow.Cabinet, resolvedCabinet.Path)); |
| 227 | 230 | ||
| 228 | try | 231 | try |
| 229 | { | 232 | { |
| @@ -237,7 +240,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 237 | } | 240 | } |
| 238 | catch (Exception e) | 241 | catch (Exception e) |
| 239 | { | 242 | { |
| 240 | Messaging.Instance.OnMessage(WixWarnings.CannotUpdateCabCache(mediaRow.SourceLineNumbers, resolvedCabinet.Path, e.Message)); | 243 | this.Messaging.Write(WarningMessages.CannotUpdateCabCache(mediaRow.SourceLineNumbers, resolvedCabinet.Path, e.Message)); |
| 241 | } | 244 | } |
| 242 | } | 245 | } |
| 243 | 246 | ||
| @@ -303,7 +306,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 303 | if (!mutex.WaitOne(0, false)) // Check if you can get the lock | 306 | if (!mutex.WaitOne(0, false)) // Check if you can get the lock |
| 304 | { | 307 | { |
| 305 | // Cound not get the Lock | 308 | // Cound not get the Lock |
| 306 | Messaging.Instance.OnMessage(WixVerboses.CabinetsSplitInParallel()); | 309 | this.Messaging.Write(VerboseMessages.CabinetsSplitInParallel()); |
| 307 | mutex.WaitOne(); // Wait on other thread | 310 | mutex.WaitOne(); // Wait on other thread |
| 308 | } | 311 | } |
| 309 | 312 | ||
| @@ -333,7 +336,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 333 | // Check if File Transfer was added | 336 | // Check if File Transfer was added |
| 334 | if (!transferAdded) | 337 | if (!transferAdded) |
| 335 | { | 338 | { |
| 336 | throw new WixException(WixErrors.SplitCabinetCopyRegistrationFailed(newCabinetName, firstCabinetName)); | 339 | throw new WixException(ErrorMessages.SplitCabinetCopyRegistrationFailed(newCabinetName, firstCabinetName)); |
| 337 | } | 340 | } |
| 338 | 341 | ||
| 339 | // Add the new Cabinets to media table using LastSequence of Base Cabinet | 342 | // Add the new Cabinets to media table using LastSequence of Base Cabinet |
| @@ -365,14 +368,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 365 | if (newCabinetName.Equals(mediaRow.Cabinet, StringComparison.InvariantCultureIgnoreCase)) | 368 | if (newCabinetName.Equals(mediaRow.Cabinet, StringComparison.InvariantCultureIgnoreCase)) |
| 366 | { | 369 | { |
| 367 | // Name Collision of generated Split Cabinet Name and user Specified Cab name for current row | 370 | // Name Collision of generated Split Cabinet Name and user Specified Cab name for current row |
| 368 | throw new WixException(WixErrors.SplitCabinetNameCollision(newCabinetName, firstCabinetName)); | 371 | throw new WixException(ErrorMessages.SplitCabinetNameCollision(newCabinetName, firstCabinetName)); |
| 369 | } | 372 | } |
| 370 | } | 373 | } |
| 371 | 374 | ||
| 372 | // Check if the last Split Cabinet was found in the Media Table | 375 | // Check if the last Split Cabinet was found in the Media Table |
| 373 | if (!lastSplitCabinetFound) | 376 | if (!lastSplitCabinetFound) |
| 374 | { | 377 | { |
| 375 | throw new WixException(WixErrors.SplitCabinetInsertionFailed(newCabinetName, firstCabinetName, lastCabinetOfThisSequence)); | 378 | throw new WixException(ErrorMessages.SplitCabinetInsertionFailed(newCabinetName, firstCabinetName, lastCabinetOfThisSequence)); |
| 376 | } | 379 | } |
| 377 | 380 | ||
| 378 | // The new Row has to be inserted just after the last cab in this cabinet split chain according to DiskID Sort | 381 | // 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 | |||
| 454 | } | 457 | } |
| 455 | catch (FormatException) | 458 | catch (FormatException) |
| 456 | { | 459 | { |
| 457 | throw new WixException(WixErrors.IllegalEnvironmentVariable("WIX_MCSLFS", mcslfsString)); | 460 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("WIX_MCSLFS", mcslfsString)); |
| 458 | } | 461 | } |
| 459 | catch (OverflowException) | 462 | catch (OverflowException) |
| 460 | { | 463 | { |
| 461 | throw new WixException(WixErrors.MaximumCabinetSizeForLargeFileSplittingTooLarge(null, maxCabSizeForLargeFileInMB, MaxValueOfMaxCabSizeForLargeFileSplitting)); | 464 | throw new WixException(ErrorMessages.MaximumCabinetSizeForLargeFileSplittingTooLarge(null, maxCabSizeForLargeFileInMB, MaxValueOfMaxCabSizeForLargeFileSplitting)); |
| 462 | } | 465 | } |
| 463 | 466 | ||
| 464 | try | 467 | try |
| @@ -476,11 +479,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 476 | } | 479 | } |
| 477 | catch (FormatException) | 480 | catch (FormatException) |
| 478 | { | 481 | { |
| 479 | throw new WixException(WixErrors.IllegalEnvironmentVariable("WIX_MUMS", mumsString)); | 482 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("WIX_MUMS", mumsString)); |
| 480 | } | 483 | } |
| 481 | catch (OverflowException) | 484 | catch (OverflowException) |
| 482 | { | 485 | { |
| 483 | throw new WixException(WixErrors.MaximumUncompressedMediaSizeTooLarge(null, maxPreCompressedSizeInMB)); | 486 | throw new WixException(ErrorMessages.MaximumUncompressedMediaSizeTooLarge(null, maxPreCompressedSizeInMB)); |
| 484 | } | 487 | } |
| 485 | 488 | ||
| 486 | maxCabSizeForLargeFileSplitting = maxCabSizeForLargeFileInMB; | 489 | maxCabSizeForLargeFileSplitting = maxCabSizeForLargeFileInMB; |
