diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index d4faabeb..83a4949e 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | |||
| @@ -97,6 +97,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 97 | if (this.CabbingThreadCount <= 0) | 97 | if (this.CabbingThreadCount <= 0) |
| 98 | { | 98 | { |
| 99 | this.CabbingThreadCount = this.CalculateCabbingThreadCount(); | 99 | this.CabbingThreadCount = this.CalculateCabbingThreadCount(); |
| 100 | |||
| 101 | this.Messaging.Write(VerboseMessages.SetCabbingThreadCount(this.CabbingThreadCount.ToString())); | ||
| 100 | } | 102 | } |
| 101 | 103 | ||
| 102 | // Send Binder object to Facilitate NewCabNamesCallBack Callback | 104 | // Send Binder object to Facilitate NewCabNamesCallBack Callback |
| @@ -137,31 +139,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 137 | 139 | ||
| 138 | private int CalculateCabbingThreadCount() | 140 | private int CalculateCabbingThreadCount() |
| 139 | { | 141 | { |
| 140 | var cabbingThreadCount = 1; // default to 1 if the environment variable is not set. | 142 | var cabbingThreadCount = Environment.ProcessorCount; |
| 141 | 143 | ||
| 142 | var numberOfProcessors = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"); | 144 | if (cabbingThreadCount <= 0) |
| 143 | |||
| 144 | try | ||
| 145 | { | 145 | { |
| 146 | if (!String.IsNullOrEmpty(numberOfProcessors)) | 146 | cabbingThreadCount = 1; // reset to 1 when the environment variable is invalid. |
| 147 | { | ||
| 148 | cabbingThreadCount = Convert.ToInt32(numberOfProcessors, CultureInfo.InvariantCulture.NumberFormat); | ||
| 149 | |||
| 150 | if (cabbingThreadCount <= 0) | ||
| 151 | { | ||
| 152 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | 147 | ||
| 156 | this.Messaging.Write(VerboseMessages.SetCabbingThreadCount(this.CabbingThreadCount.ToString())); | 148 | this.Messaging.Write(WarningMessages.InvalidEnvironmentVariable("NUMBER_OF_PROCESSORS", Environment.ProcessorCount.ToString(), cabbingThreadCount.ToString())); |
| 157 | } | ||
| 158 | catch (ArgumentException) | ||
| 159 | { | ||
| 160 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | ||
| 161 | } | ||
| 162 | catch (FormatException) | ||
| 163 | { | ||
| 164 | throw new WixException(ErrorMessages.IllegalEnvironmentVariable("NUMBER_OF_PROCESSORS", numberOfProcessors)); | ||
| 165 | } | 149 | } |
| 166 | 150 | ||
| 167 | return cabbingThreadCount; | 151 | return cabbingThreadCount; |
