diff options
Diffstat (limited to 'src')
4 files changed, 50 insertions, 79 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 5c84a82f..32da410f 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |||
| @@ -452,7 +452,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 452 | command.FileRowsByCabinet = filesByCabinetMedia; | 452 | command.FileRowsByCabinet = filesByCabinetMedia; |
| 453 | command.ResolveMedia = this.ResolveMedia; | 453 | command.ResolveMedia = this.ResolveMedia; |
| 454 | command.TableDefinitions = tableDefinitions; | 454 | command.TableDefinitions = tableDefinitions; |
| 455 | command.TempFilesLocation = this.IntermediateFolder; | 455 | command.IntermediateFolder = this.IntermediateFolder; |
| 456 | command.Execute(); | 456 | command.Execute(); |
| 457 | 457 | ||
| 458 | fileTransfers.AddRange(command.FileTransfers); | 458 | fileTransfers.AddRange(command.FileTransfers); |
| @@ -887,8 +887,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 887 | /// </remarks> | 887 | /// </remarks> |
| 888 | private void ValidateComponentGuids(WindowsInstallerData output) | 888 | private void ValidateComponentGuids(WindowsInstallerData output) |
| 889 | { | 889 | { |
| 890 | Table componentTable = output.Tables["Component"]; | 890 | if (output.TryGetTable("Component", out var componentTable)) |
| 891 | if (null != componentTable) | ||
| 892 | { | 891 | { |
| 893 | Dictionary<string, bool> componentGuidConditions = new Dictionary<string, bool>(componentTable.Rows.Count); | 892 | Dictionary<string, bool> componentGuidConditions = new Dictionary<string, bool>(componentTable.Rows.Count); |
| 894 | 893 | ||
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs index 5f19fd2a..e7d67d8c 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs | |||
| @@ -150,13 +150,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 150 | // Get the Value for Max Uncompressed Media Size | 150 | // Get the Value for Max Uncompressed Media Size |
| 151 | maxPreCompressedSizeInBytes = (ulong)this.MaximumUncompressedMediaSize * 1024 * 1024; | 151 | maxPreCompressedSizeInBytes = (ulong)this.MaximumUncompressedMediaSize * 1024 * 1024; |
| 152 | 152 | ||
| 153 | foreach (FileFacade facade in cabinetWorkItem.FileFacades) // No other easy way than looping to get the only row | 153 | var facade = cabinetWorkItem.FileFacades.First(); |
| 154 | |||
| 155 | // If the file is larger than MaximumUncompressedFileSize set Maximum Cabinet Size for Cabinet Splitting | ||
| 156 | if ((ulong)facade.FileSize >= maxPreCompressedSizeInBytes) | ||
| 154 | { | 157 | { |
| 155 | if ((ulong)facade.FileSize >= maxPreCompressedSizeInBytes) | 158 | maxCabinetSize = this.MaximumCabinetSizeForLargeFileSplitting; |
| 156 | { | ||
| 157 | // If file is larger than MaximumUncompressedFileSize set Maximum Cabinet Size for Cabinet Splitting | ||
| 158 | maxCabinetSize = this.MaximumCabinetSizeForLargeFileSplitting; | ||
| 159 | } | ||
| 160 | } | 159 | } |
| 161 | } | 160 | } |
| 162 | } | 161 | } |
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetWorkItem.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetWorkItem.cs index 760b5fb9..a451229f 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetWorkItem.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetWorkItem.cs | |||
| @@ -11,11 +11,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 11 | /// </summary> | 11 | /// </summary> |
| 12 | internal sealed class CabinetWorkItem | 12 | internal sealed class CabinetWorkItem |
| 13 | { | 13 | { |
| 14 | private string cabinetFile; | ||
| 15 | private CompressionLevel compressionLevel; | ||
| 16 | //private BinderFileManager binderFileManager; | ||
| 17 | private int maxThreshold; | ||
| 18 | |||
| 19 | /// <summary> | 14 | /// <summary> |
| 20 | /// Instantiate a new CabinetWorkItem. | 15 | /// Instantiate a new CabinetWorkItem. |
| 21 | /// </summary> | 16 | /// </summary> |
| @@ -24,34 +19,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 24 | /// <param name="maxThreshold">Maximum threshold for each cabinet.</param> | 19 | /// <param name="maxThreshold">Maximum threshold for each cabinet.</param> |
| 25 | /// <param name="compressionLevel">The compression level of the cabinet.</param> | 20 | /// <param name="compressionLevel">The compression level of the cabinet.</param> |
| 26 | /// <param name="binderFileManager">The binder file manager.</param> | 21 | /// <param name="binderFileManager">The binder file manager.</param> |
| 27 | public CabinetWorkItem(IEnumerable<FileFacade> fileFacades, string cabinetFile, int maxThreshold, CompressionLevel compressionLevel /*, BinderFileManager binderFileManager*/) | ||
| 28 | public CabinetWorkItem(IEnumerable<FileFacade> fileFacades, string cabinetFile, int maxThreshold, CompressionLevel compressionLevel, string modularizationSuffix /*, BinderFileManager binderFileManager*/) | 22 | public CabinetWorkItem(IEnumerable<FileFacade> fileFacades, string cabinetFile, int maxThreshold, CompressionLevel compressionLevel, string modularizationSuffix /*, BinderFileManager binderFileManager*/) |
| 29 | { | 23 | { |
| 30 | this.cabinetFile = cabinetFile; | 24 | this.CabinetFile = cabinetFile; |
| 31 | this.compressionLevel = compressionLevel; | 25 | this.CompressionLevel = compressionLevel; |
| 32 | this.ModularizationSuffix = modularizationSuffix; | 26 | this.ModularizationSuffix = modularizationSuffix; |
| 33 | this.FileFacades = fileFacades; | 27 | this.FileFacades = fileFacades; |
| 34 | //this.binderFileManager = binderFileManager; | 28 | //this.BinderFileManager = binderFileManager; |
| 35 | this.maxThreshold = maxThreshold; | 29 | this.MaxThreshold = maxThreshold; |
| 36 | } | 30 | } |
| 37 | 31 | ||
| 38 | /// <summary> | 32 | /// <summary> |
| 39 | /// Gets the cabinet file. | 33 | /// Gets the cabinet file. |
| 40 | /// </summary> | 34 | /// </summary> |
| 41 | /// <value>The cabinet file.</value> | 35 | /// <value>The cabinet file.</value> |
| 42 | public string CabinetFile | 36 | public string CabinetFile { get; } |
| 43 | { | ||
| 44 | get { return this.cabinetFile; } | ||
| 45 | } | ||
| 46 | 37 | ||
| 47 | /// <summary> | 38 | /// <summary> |
| 48 | /// Gets the compression level of the cabinet. | 39 | /// Gets the compression level of the cabinet. |
| 49 | /// </summary> | 40 | /// </summary> |
| 50 | /// <value>The compression level of the cabinet.</value> | 41 | /// <value>The compression level of the cabinet.</value> |
| 51 | public CompressionLevel CompressionLevel | 42 | public CompressionLevel CompressionLevel { get; } |
| 52 | { | ||
| 53 | get { return this.compressionLevel; } | ||
| 54 | } | ||
| 55 | 43 | ||
| 56 | /// <summary> | 44 | /// <summary> |
| 57 | /// Gets the modularization suffix used when building a Merge Module. | 45 | /// Gets the modularization suffix used when building a Merge Module. |
| @@ -62,24 +50,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 62 | /// Gets the collection of files in this cabinet. | 50 | /// Gets the collection of files in this cabinet. |
| 63 | /// </summary> | 51 | /// </summary> |
| 64 | /// <value>The collection of files in this cabinet.</value> | 52 | /// <value>The collection of files in this cabinet.</value> |
| 65 | public IEnumerable<FileFacade> FileFacades { get; private set; } | 53 | public IEnumerable<FileFacade> FileFacades { get; } |
| 66 | 54 | ||
| 67 | /// <summary> | 55 | /// <summary> |
| 68 | /// Gets the binder file manager. | 56 | /// Gets the binder file manager. |
| 69 | /// </summary> | 57 | /// </summary> |
| 70 | /// <value>The binder file manager.</value> | 58 | /// <value>The binder file manager.</value> |
| 71 | //public BinderFileManager BinderFileManager | 59 | //public BinderFileManager BinderFileManager { get; private set; } |
| 72 | //{ | ||
| 73 | // get { return this.binderFileManager; } | ||
| 74 | //} | ||
| 75 | 60 | ||
| 76 | /// <summary> | 61 | /// <summary> |
| 77 | /// Gets the max threshold. | 62 | /// Gets the max threshold. |
| 78 | /// </summary> | 63 | /// </summary> |
| 79 | /// <value>The maximum threshold for a folder in a cabinet.</value> | 64 | /// <value>The maximum threshold for a folder in a cabinet.</value> |
| 80 | public int MaxThreshold | 65 | public int MaxThreshold { get; } |
| 81 | { | ||
| 82 | get { return this.maxThreshold; } | ||
| 83 | } | ||
| 84 | } | 66 | } |
| 85 | } | 67 | } |
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index 6852772e..f2f9895d 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | |||
| @@ -59,7 +59,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 59 | 59 | ||
| 60 | public IMessaging Messaging { private get; set; } | 60 | public IMessaging Messaging { private get; set; } |
| 61 | 61 | ||
| 62 | public string TempFilesLocation { private get; set; } | 62 | public string IntermediateFolder { private get; set; } |
| 63 | 63 | ||
| 64 | /// <summary> | 64 | /// <summary> |
| 65 | /// Sets the default compression level to use for cabinets | 65 | /// Sets the default compression level to use for cabinets |
| @@ -95,15 +95,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 95 | { | 95 | { |
| 96 | this.lastCabinetAddedToMediaTable = new Dictionary<string, string>(); | 96 | this.lastCabinetAddedToMediaTable = new Dictionary<string, string>(); |
| 97 | 97 | ||
| 98 | this.SetCabbingThreadCount(); | 98 | // If the cabbing thread count wasn't provided, default the number of cabbing threads to the number of processors. |
| 99 | if (this.CabbingThreadCount <= 0) | ||
| 100 | { | ||
| 101 | this.CabbingThreadCount = this.CalculateCabbingThreadCount(); | ||
| 102 | } | ||
| 99 | 103 | ||
| 100 | // Send Binder object to Facilitate NewCabNamesCallBack Callback | 104 | // Send Binder object to Facilitate NewCabNamesCallBack Callback |
| 101 | var cabinetBuilder = new CabinetBuilder(this.Messaging, this.CabbingThreadCount, Marshal.GetFunctionPointerForDelegate(this.newCabNamesCallBack)); | 105 | var cabinetBuilder = new CabinetBuilder(this.Messaging, this.CabbingThreadCount, Marshal.GetFunctionPointerForDelegate(this.newCabNamesCallBack)); |
| 102 | 106 | ||
| 103 | // Supply Compile MediaTemplate Attributes to Cabinet Builder | 107 | // Supply Compile MediaTemplate Attributes to Cabinet Builder |
| 104 | this.GetMediaTemplateAttributes(out var MaximumCabinetSizeForLargeFileSplitting, out var MaximumUncompressedMediaSize); | 108 | this.GetMediaTemplateAttributes(out var maximumCabinetSizeForLargeFileSplitting, out var maximumUncompressedMediaSize); |
| 105 | cabinetBuilder.MaximumCabinetSizeForLargeFileSplitting = MaximumCabinetSizeForLargeFileSplitting; | 109 | cabinetBuilder.MaximumCabinetSizeForLargeFileSplitting = maximumCabinetSizeForLargeFileSplitting; |
| 106 | cabinetBuilder.MaximumUncompressedMediaSize = MaximumUncompressedMediaSize; | 110 | cabinetBuilder.MaximumUncompressedMediaSize = maximumUncompressedMediaSize; |
| 107 | 111 | ||
| 108 | foreach (var entry in this.FileRowsByCabinet) | 112 | foreach (var entry in this.FileRowsByCabinet) |
| 109 | { | 113 | { |
| @@ -133,44 +137,36 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 133 | } | 137 | } |
| 134 | } | 138 | } |
| 135 | 139 | ||
| 136 | /// <summary> | 140 | private int CalculateCabbingThreadCount() |
| 137 | /// Sets the thead count to the number of processors if the current thread count is set to 0. | ||
| 138 | /// </summary> | ||
| 139 | /// <remarks>The thread count value must be greater than 0 otherwise and exception will be thrown.</remarks> | ||
| 140 | private void SetCabbingThreadCount() | ||
| 141 | { | 141 | { |
| 142 | // default the number of cabbing threads to the number of processors if it wasn't specified | 142 | var cabbingThreadCount = 1; // default to 1 if the environment variable is not set. |
| 143 | if (0 == this.CabbingThreadCount) | ||
| 144 | { | ||
| 145 | string numberOfProcessors = System.Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"); | ||
| 146 | 143 | ||
| 147 | try | 144 | var numberOfProcessors = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"); |
| 145 | |||
| 146 | try | ||
| 147 | { | ||
| 148 | if (!String.IsNullOrEmpty(numberOfProcessors)) | ||
| 148 | { | 149 | { |
| 149 | if (null != numberOfProcessors) | 150 | cabbingThreadCount = Convert.ToInt32(numberOfProcessors, CultureInfo.InvariantCulture.NumberFormat); |
| 150 | { | ||
| 151 | this.CabbingThreadCount = Convert.ToInt32(numberOfProcessors, CultureInfo.InvariantCulture.NumberFormat); | ||
| 152 | 151 | ||
| 153 | if (0 >= this.CabbingThreadCount) | 152 | if (cabbingThreadCount <= 0) |
| 154 | { | ||
| 155 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | ||
| 156 | } | ||
| 157 | } | ||
| 158 | else // default to 1 if the environment variable is not set | ||
| 159 | { | 153 | { |
| 160 | this.CabbingThreadCount = 1; | 154 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); |
| 161 | } | 155 | } |
| 162 | |||
| 163 | this.Messaging.Write(VerboseMessages.SetCabbingThreadCount(this.CabbingThreadCount.ToString())); | ||
| 164 | } | ||
| 165 | catch (ArgumentException) | ||
| 166 | { | ||
| 167 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | ||
| 168 | } | ||
| 169 | catch (FormatException) | ||
| 170 | { | ||
| 171 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | ||
| 172 | } | 156 | } |
| 157 | |||
| 158 | this.Messaging.Write(VerboseMessages.SetCabbingThreadCount(this.CabbingThreadCount.ToString())); | ||
| 159 | } | ||
| 160 | catch (ArgumentException) | ||
| 161 | { | ||
| 162 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | ||
| 173 | } | 163 | } |
| 164 | catch (FormatException) | ||
| 165 | { | ||
| 166 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | ||
| 167 | } | ||
| 168 | |||
| 169 | return cabbingThreadCount; | ||
| 174 | } | 170 | } |
| 175 | 171 | ||
| 176 | 172 | ||
| @@ -185,18 +181,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 185 | private CabinetWorkItem CreateCabinetWorkItem(WindowsInstallerData output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable<FileFacade> fileFacades) | 181 | private CabinetWorkItem CreateCabinetWorkItem(WindowsInstallerData output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable<FileFacade> fileFacades) |
| 186 | { | 182 | { |
| 187 | CabinetWorkItem cabinetWorkItem = null; | 183 | CabinetWorkItem cabinetWorkItem = null; |
| 188 | string tempCabinetFileX = Path.Combine(this.TempFilesLocation, mediaRow.Cabinet); | 184 | string tempCabinetFileX = Path.Combine(this.IntermediateFolder, mediaRow.Cabinet); |
| 189 | 185 | ||
| 190 | // check for an empty cabinet | 186 | // check for an empty cabinet |
| 191 | if (!fileFacades.Any()) | 187 | if (!fileFacades.Any()) |
| 192 | { | 188 | { |
| 193 | string cabinetName = mediaRow.Cabinet; | 189 | // Remove the leading '#' from the embedded cabinet name to make the warning easier to understand |
| 194 | 190 | var cabinetName = mediaRow.Cabinet.TrimStart('#'); | |
| 195 | // remove the leading '#' from the embedded cabinet name to make the warning easier to understand | ||
| 196 | if (cabinetName.StartsWith("#", StringComparison.Ordinal)) | ||
| 197 | { | ||
| 198 | cabinetName = cabinetName.Substring(1); | ||
| 199 | } | ||
| 200 | 191 | ||
| 201 | // If building a patch, remind them to run -p for torch. | 192 | // If building a patch, remind them to run -p for torch. |
| 202 | if (OutputType.Patch == output.Type) | 193 | if (OutputType.Patch == output.Type) |
