diff options
| author | Rob Mensching <rob@firegiant.com> | 2020-06-12 12:55:28 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2020-06-13 09:22:27 -0700 |
| commit | c0f1332a0e18e9d506fe80c328548b001dcf93df (patch) | |
| tree | 4980dddd35350e79b00a61574feafa859e857e3f /src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | |
| parent | 167d26d002b1412e72d96ed2bbc0761fc0f1344b (diff) | |
| download | wix-c0f1332a0e18e9d506fe80c328548b001dcf93df.tar.gz wix-c0f1332a0e18e9d506fe80c328548b001dcf93df.tar.bz2 wix-c0f1332a0e18e9d506fe80c328548b001dcf93df.zip | |
Remove use of remaining WixXxxRows
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | 89 |
1 files changed, 36 insertions, 53 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index f2f9895d..de357e53 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | |||
| @@ -12,7 +12,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 12 | using WixToolset.Data; | 12 | using WixToolset.Data; |
| 13 | using WixToolset.Data.Tuples; | 13 | using WixToolset.Data.Tuples; |
| 14 | using WixToolset.Data.WindowsInstaller; | 14 | using WixToolset.Data.WindowsInstaller; |
| 15 | using WixToolset.Data.WindowsInstaller.Rows; | ||
| 16 | using WixToolset.Extensibility; | 15 | using WixToolset.Extensibility; |
| 17 | using WixToolset.Extensibility.Data; | 16 | using WixToolset.Extensibility.Data; |
| 18 | using WixToolset.Extensibility.Services; | 17 | using WixToolset.Extensibility.Services; |
| @@ -33,7 +32,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 33 | 32 | ||
| 34 | private Dictionary<string, string> lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence | 33 | private Dictionary<string, string> lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence |
| 35 | 34 | ||
| 36 | public CreateCabinetsCommand(IWixToolsetServiceProvider serviceProvider, IBackendHelper backendHelper) | 35 | public CreateCabinetsCommand(IWixToolsetServiceProvider serviceProvider, IBackendHelper backendHelper, WixMediaTemplateTuple mediaTemplate) |
| 37 | { | 36 | { |
| 38 | this.fileTransfers = new List<IFileTransfer>(); | 37 | this.fileTransfers = new List<IFileTransfer>(); |
| 39 | 38 | ||
| @@ -44,11 +43,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 44 | this.ServiceProvider = serviceProvider; | 43 | this.ServiceProvider = serviceProvider; |
| 45 | 44 | ||
| 46 | this.BackendHelper = backendHelper; | 45 | this.BackendHelper = backendHelper; |
| 46 | |||
| 47 | this.MediaTemplate = mediaTemplate; | ||
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | public IWixToolsetServiceProvider ServiceProvider { get; } | 50 | private IWixToolsetServiceProvider ServiceProvider { get; } |
| 51 | |||
| 52 | private IBackendHelper BackendHelper { get; } | ||
| 50 | 53 | ||
| 51 | public IBackendHelper BackendHelper { get; } | 54 | private WixMediaTemplateTuple MediaTemplate { get; } |
| 52 | 55 | ||
| 53 | /// <summary> | 56 | /// <summary> |
| 54 | /// Sets the number of threads to use for cabinet creation. | 57 | /// Sets the number of threads to use for cabinet creation. |
| @@ -77,7 +80,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 77 | 80 | ||
| 78 | public string ModularizationSuffix { private get; set; } | 81 | public string ModularizationSuffix { private get; set; } |
| 79 | 82 | ||
| 80 | public Dictionary<MediaTuple, IEnumerable<FileFacade>> FileRowsByCabinet { private get; set; } | 83 | public Dictionary<MediaTuple, IEnumerable<FileFacade>> FileFacadesByCabinet { private get; set; } |
| 81 | 84 | ||
| 82 | public Func<MediaTuple, string, string, string> ResolveMedia { private get; set; } | 85 | public Func<MediaTuple, string, string, string> ResolveMedia { private get; set; } |
| 83 | 86 | ||
| @@ -90,7 +93,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 90 | /// <param name="output">Output to generate image for.</param> | 93 | /// <param name="output">Output to generate image for.</param> |
| 91 | /// <param name="layoutDirectory">The directory in which the image should be layed out.</param> | 94 | /// <param name="layoutDirectory">The directory in which the image should be layed out.</param> |
| 92 | /// <param name="compressed">Flag if source image should be compressed.</param> | 95 | /// <param name="compressed">Flag if source image should be compressed.</param> |
| 93 | /// <returns>The uncompressed file rows.</returns> | ||
| 94 | public void Execute() | 96 | public void Execute() |
| 95 | { | 97 | { |
| 96 | this.lastCabinetAddedToMediaTable = new Dictionary<string, string>(); | 98 | this.lastCabinetAddedToMediaTable = new Dictionary<string, string>(); |
| @@ -109,7 +111,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 109 | cabinetBuilder.MaximumCabinetSizeForLargeFileSplitting = maximumCabinetSizeForLargeFileSplitting; | 111 | cabinetBuilder.MaximumCabinetSizeForLargeFileSplitting = maximumCabinetSizeForLargeFileSplitting; |
| 110 | cabinetBuilder.MaximumUncompressedMediaSize = maximumUncompressedMediaSize; | 112 | cabinetBuilder.MaximumUncompressedMediaSize = maximumUncompressedMediaSize; |
| 111 | 113 | ||
| 112 | foreach (var entry in this.FileRowsByCabinet) | 114 | foreach (var entry in this.FileFacadesByCabinet) |
| 113 | { | 115 | { |
| 114 | var mediaTuple = entry.Key; | 116 | var mediaTuple = entry.Key; |
| 115 | var files = entry.Value; | 117 | var files = entry.Value; |
| @@ -175,28 +177,28 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 175 | /// </summary> | 177 | /// </summary> |
| 176 | /// <param name="output">Output for the current database.</param> | 178 | /// <param name="output">Output for the current database.</param> |
| 177 | /// <param name="cabinetDir">Directory to create cabinet in.</param> | 179 | /// <param name="cabinetDir">Directory to create cabinet in.</param> |
| 178 | /// <param name="mediaRow">MediaRow containing information about the cabinet.</param> | 180 | /// <param name="mediaTuple">Media tuple containing information about the cabinet.</param> |
| 179 | /// <param name="fileFacades">Collection of files in this cabinet.</param> | 181 | /// <param name="fileFacades">Collection of files in this cabinet.</param> |
| 180 | /// <returns>created CabinetWorkItem object</returns> | 182 | /// <returns>created CabinetWorkItem object</returns> |
| 181 | private CabinetWorkItem CreateCabinetWorkItem(WindowsInstallerData output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable<FileFacade> fileFacades) | 183 | private CabinetWorkItem CreateCabinetWorkItem(WindowsInstallerData output, string cabinetDir, MediaTuple mediaTuple, CompressionLevel compressionLevel, IEnumerable<FileFacade> fileFacades) |
| 182 | { | 184 | { |
| 183 | CabinetWorkItem cabinetWorkItem = null; | 185 | CabinetWorkItem cabinetWorkItem = null; |
| 184 | string tempCabinetFileX = Path.Combine(this.IntermediateFolder, mediaRow.Cabinet); | 186 | var tempCabinetFileX = Path.Combine(this.IntermediateFolder, mediaTuple.Cabinet); |
| 185 | 187 | ||
| 186 | // check for an empty cabinet | 188 | // check for an empty cabinet |
| 187 | if (!fileFacades.Any()) | 189 | if (!fileFacades.Any()) |
| 188 | { | 190 | { |
| 189 | // Remove the leading '#' from the embedded cabinet name to make the warning easier to understand | 191 | // Remove the leading '#' from the embedded cabinet name to make the warning easier to understand |
| 190 | var cabinetName = mediaRow.Cabinet.TrimStart('#'); | 192 | var cabinetName = mediaTuple.Cabinet.TrimStart('#'); |
| 191 | 193 | ||
| 192 | // If building a patch, remind them to run -p for torch. | 194 | // If building a patch, remind them to run -p for torch. |
| 193 | if (OutputType.Patch == output.Type) | 195 | if (OutputType.Patch == output.Type) |
| 194 | { | 196 | { |
| 195 | this.Messaging.Write(WarningMessages.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName, true)); | 197 | this.Messaging.Write(WarningMessages.EmptyCabinet(mediaTuple.SourceLineNumbers, cabinetName, true)); |
| 196 | } | 198 | } |
| 197 | else | 199 | else |
| 198 | { | 200 | { |
| 199 | this.Messaging.Write(WarningMessages.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName)); | 201 | this.Messaging.Write(WarningMessages.EmptyCabinet(mediaTuple.SourceLineNumbers, cabinetName)); |
| 200 | } | 202 | } |
| 201 | } | 203 | } |
| 202 | 204 | ||
| @@ -212,7 +214,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 212 | } | 214 | } |
| 213 | else // reuse the cabinet from the cabinet cache. | 215 | else // reuse the cabinet from the cabinet cache. |
| 214 | { | 216 | { |
| 215 | this.Messaging.Write(VerboseMessages.ReusingCabCache(mediaRow.SourceLineNumbers, mediaRow.Cabinet, resolvedCabinet.Path)); | 217 | this.Messaging.Write(VerboseMessages.ReusingCabCache(mediaTuple.SourceLineNumbers, mediaTuple.Cabinet, resolvedCabinet.Path)); |
| 216 | 218 | ||
| 217 | try | 219 | try |
| 218 | { | 220 | { |
| @@ -226,27 +228,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 226 | } | 228 | } |
| 227 | catch (Exception e) | 229 | catch (Exception e) |
| 228 | { | 230 | { |
| 229 | this.Messaging.Write(WarningMessages.CannotUpdateCabCache(mediaRow.SourceLineNumbers, resolvedCabinet.Path, e.Message)); | 231 | this.Messaging.Write(WarningMessages.CannotUpdateCabCache(mediaTuple.SourceLineNumbers, resolvedCabinet.Path, e.Message)); |
| 230 | } | 232 | } |
| 231 | } | 233 | } |
| 232 | 234 | ||
| 233 | var trackResolvedCabinet = this.BackendHelper.TrackFile(resolvedCabinet.Path, TrackedFileType.Intermediate, mediaRow.SourceLineNumbers); | 235 | var trackResolvedCabinet = this.BackendHelper.TrackFile(resolvedCabinet.Path, TrackedFileType.Intermediate, mediaTuple.SourceLineNumbers); |
| 234 | this.trackedFiles.Add(trackResolvedCabinet); | 236 | this.trackedFiles.Add(trackResolvedCabinet); |
| 235 | 237 | ||
| 236 | if (mediaRow.Cabinet.StartsWith("#", StringComparison.Ordinal)) | 238 | if (mediaTuple.Cabinet.StartsWith("#", StringComparison.Ordinal)) |
| 237 | { | 239 | { |
| 238 | var streamsTable = output.EnsureTable(this.TableDefinitions["_Streams"]); | 240 | var streamsTable = output.EnsureTable(this.TableDefinitions["_Streams"]); |
| 239 | 241 | ||
| 240 | var streamRow = streamsTable.CreateRow(mediaRow.SourceLineNumbers); | 242 | var streamRow = streamsTable.CreateRow(mediaTuple.SourceLineNumbers); |
| 241 | streamRow[0] = mediaRow.Cabinet.Substring(1); | 243 | streamRow[0] = mediaTuple.Cabinet.Substring(1); |
| 242 | streamRow[1] = resolvedCabinet.Path; | 244 | streamRow[1] = resolvedCabinet.Path; |
| 243 | } | 245 | } |
| 244 | else | 246 | else |
| 245 | { | 247 | { |
| 246 | var trackDestination = this.BackendHelper.TrackFile(Path.Combine(cabinetDir, mediaRow.Cabinet), TrackedFileType.Final, mediaRow.SourceLineNumbers); | 248 | var trackDestination = this.BackendHelper.TrackFile(Path.Combine(cabinetDir, mediaTuple.Cabinet), TrackedFileType.Final, mediaTuple.SourceLineNumbers); |
| 247 | this.trackedFiles.Add(trackDestination); | 249 | this.trackedFiles.Add(trackDestination); |
| 248 | 250 | ||
| 249 | var transfer = this.BackendHelper.CreateFileTransfer(resolvedCabinet.Path, trackDestination.Path, resolvedCabinet.BuildOption == CabinetBuildOption.BuildAndMove, mediaRow.SourceLineNumbers); | 251 | var transfer = this.BackendHelper.CreateFileTransfer(resolvedCabinet.Path, trackDestination.Path, resolvedCabinet.BuildOption == CabinetBuildOption.BuildAndMove, mediaTuple.SourceLineNumbers); |
| 250 | this.fileTransfers.Add(transfer); | 252 | this.fileTransfers.Add(transfer); |
| 251 | } | 253 | } |
| 252 | 254 | ||
| @@ -417,36 +419,24 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 417 | /// <summary> | 419 | /// <summary> |
| 418 | /// Gets Compiler Values of MediaTemplate Attributes governing Maximum Cabinet Size after applying Environment Variable Overrides | 420 | /// Gets Compiler Values of MediaTemplate Attributes governing Maximum Cabinet Size after applying Environment Variable Overrides |
| 419 | /// </summary> | 421 | /// </summary> |
| 420 | /// <param name="output">Output to generate image for.</param> | ||
| 421 | /// <param name="fileRows">The indexed file rows.</param> | ||
| 422 | private void GetMediaTemplateAttributes(out int maxCabSizeForLargeFileSplitting, out int maxUncompressedMediaSize) | 422 | private void GetMediaTemplateAttributes(out int maxCabSizeForLargeFileSplitting, out int maxUncompressedMediaSize) |
| 423 | { | 423 | { |
| 424 | // Get Environment Variable Overrides for MediaTemplate Attributes governing Maximum Cabinet Size | 424 | // Get Environment Variable Overrides for MediaTemplate Attributes governing Maximum Cabinet Size |
| 425 | string mcslfsString = Environment.GetEnvironmentVariable("WIX_MCSLFS"); | 425 | var mcslfsString = Environment.GetEnvironmentVariable("WIX_MCSLFS"); |
| 426 | string mumsString = Environment.GetEnvironmentVariable("WIX_MUMS"); | 426 | var mumsString = Environment.GetEnvironmentVariable("WIX_MUMS"); |
| 427 | int maxCabSizeForLargeFileInMB = 0; | ||
| 428 | int maxPreCompressedSizeInMB = 0; | ||
| 429 | ulong testOverFlow = 0; | ||
| 430 | 427 | ||
| 431 | // Supply Compile MediaTemplate Attributes to Cabinet Builder | 428 | // Supply Compile MediaTemplate Attributes to Cabinet Builder |
| 432 | Table mediaTemplateTable = this.Output.Tables["WixMediaTemplate"]; | 429 | if (this.MediaTemplate != null) |
| 433 | if (mediaTemplateTable != null) | ||
| 434 | { | 430 | { |
| 435 | WixMediaTemplateRow mediaTemplateRow = (WixMediaTemplateRow)mediaTemplateTable.Rows[0]; | ||
| 436 | |||
| 437 | // Get the Value for Max Cab Size for File Splitting | 431 | // Get the Value for Max Cab Size for File Splitting |
| 432 | var maxCabSizeForLargeFileInMB = 0; | ||
| 438 | try | 433 | try |
| 439 | { | 434 | { |
| 440 | // Override authored mcslfs value if environment variable is authored. | 435 | // Override authored mcslfs value if environment variable is authored. |
| 441 | if (!String.IsNullOrEmpty(mcslfsString)) | 436 | maxCabSizeForLargeFileInMB = !String.IsNullOrEmpty(mcslfsString) ? Int32.Parse(mcslfsString) : this.MediaTemplate.MaximumCabinetSizeForLargeFileSplitting ?? MaxValueOfMaxCabSizeForLargeFileSplitting; |
| 442 | { | 437 | |
| 443 | maxCabSizeForLargeFileInMB = Int32.Parse(mcslfsString); | 438 | var testOverFlow = (ulong)maxCabSizeForLargeFileInMB * 1024 * 1024; |
| 444 | } | 439 | maxCabSizeForLargeFileSplitting = maxCabSizeForLargeFileInMB; |
| 445 | else | ||
| 446 | { | ||
| 447 | maxCabSizeForLargeFileInMB = mediaTemplateRow.MaximumCabinetSizeForLargeFileSplitting; | ||
| 448 | } | ||
| 449 | testOverFlow = (ulong)maxCabSizeForLargeFileInMB * 1024 * 1024; | ||
| 450 | } | 440 | } |
| 451 | catch (FormatException) | 441 | catch (FormatException) |
| 452 | { | 442 | { |
| @@ -457,18 +447,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 457 | throw new WixException(ErrorMessages.MaximumCabinetSizeForLargeFileSplittingTooLarge(null, maxCabSizeForLargeFileInMB, MaxValueOfMaxCabSizeForLargeFileSplitting)); | 447 | throw new WixException(ErrorMessages.MaximumCabinetSizeForLargeFileSplittingTooLarge(null, maxCabSizeForLargeFileInMB, MaxValueOfMaxCabSizeForLargeFileSplitting)); |
| 458 | } | 448 | } |
| 459 | 449 | ||
| 450 | var maxPreCompressedSizeInMB = 0; | ||
| 460 | try | 451 | try |
| 461 | { | 452 | { |
| 462 | // Override authored mums value if environment variable is authored. | 453 | // Override authored mums value if environment variable is authored. |
| 463 | if (!String.IsNullOrEmpty(mumsString)) | 454 | maxPreCompressedSizeInMB = !String.IsNullOrEmpty(mumsString) ? Int32.Parse(mumsString) : this.MediaTemplate.MaximumUncompressedMediaSize ?? DefaultMaximumUncompressedMediaSize; |
| 464 | { | 455 | |
| 465 | maxPreCompressedSizeInMB = Int32.Parse(mumsString); | 456 | var testOverFlow = (ulong)maxPreCompressedSizeInMB * 1024 * 1024; |
| 466 | } | 457 | maxUncompressedMediaSize = maxPreCompressedSizeInMB; |
| 467 | else | ||
| 468 | { | ||
| 469 | maxPreCompressedSizeInMB = mediaTemplateRow.MaximumUncompressedMediaSize; | ||
| 470 | } | ||
| 471 | testOverFlow = (ulong)maxPreCompressedSizeInMB * 1024 * 1024; | ||
| 472 | } | 458 | } |
| 473 | catch (FormatException) | 459 | catch (FormatException) |
| 474 | { | 460 | { |
| @@ -478,9 +464,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 478 | { | 464 | { |
| 479 | throw new WixException(ErrorMessages.MaximumUncompressedMediaSizeTooLarge(null, maxPreCompressedSizeInMB)); | 465 | throw new WixException(ErrorMessages.MaximumUncompressedMediaSizeTooLarge(null, maxPreCompressedSizeInMB)); |
| 480 | } | 466 | } |
| 481 | |||
| 482 | maxCabSizeForLargeFileSplitting = maxCabSizeForLargeFileInMB; | ||
| 483 | maxUncompressedMediaSize = maxPreCompressedSizeInMB; | ||
| 484 | } | 467 | } |
| 485 | else | 468 | else |
| 486 | { | 469 | { |
