diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/api/wix/WixToolset.Data/ErrorMessages.cs | 4 | ||||
| -rw-r--r-- | src/wix/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs | 42 |
2 files changed, 34 insertions, 12 deletions
diff --git a/src/api/wix/WixToolset.Data/ErrorMessages.cs b/src/api/wix/WixToolset.Data/ErrorMessages.cs index aa9750a8..35bd23c5 100644 --- a/src/api/wix/WixToolset.Data/ErrorMessages.cs +++ b/src/api/wix/WixToolset.Data/ErrorMessages.cs | |||
| @@ -180,12 +180,12 @@ namespace WixToolset.Data | |||
| 180 | 180 | ||
| 181 | public static Message CreateCabAddFileFailed() | 181 | public static Message CreateCabAddFileFailed() |
| 182 | { | 182 | { |
| 183 | return Message(null, Ids.CreateCabAddFileFailed, "An error (E_FAIL) was returned while adding files to a CAB file. This most commonly happens when creating a CAB file 2 GB or larger. Either reduce the size of your installation package, raise Media/@CompressionLevel to a higher compression level, or split your installation package's files into more than one CAB file."); | 183 | return Message(null, Ids.CreateCabAddFileFailed, "An error (E_FAIL) was returned while creating a CAB file. The most common cause of this error is attempting to create a CAB file larger than 2GB. You can reduce the size of your installation package, use a higher compression level, or split your files into more than one CAB file."); |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | public static Message CreateCabInsufficientDiskSpace() | 186 | public static Message CreateCabInsufficientDiskSpace() |
| 187 | { | 187 | { |
| 188 | return Message(null, Ids.CreateCabInsufficientDiskSpace, "An error (ERROR_DISK_FULL) was returned while creating a CAB file. This means you have insufficient disk space - please clear more disk space and try this operation again."); | 188 | return Message(null, Ids.CreateCabInsufficientDiskSpace, "An error (ERROR_DISK_FULL) was returned while creating a CAB file. This means you have insufficient disk space. Clear disk space and try again."); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | public static Message CubeFileNotFound(string cubeFile) | 191 | public static Message CubeFileNotFound(string cubeFile) |
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs index 93aad0a6..cc052510 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs | |||
| @@ -4,6 +4,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 7 | using System.ComponentModel; | ||
| 7 | using System.IO; | 8 | using System.IO; |
| 8 | using System.Linq; | 9 | using System.Linq; |
| 9 | using System.Threading; | 10 | using System.Threading; |
| @@ -122,9 +123,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 122 | var created = this.CreateCabinet(cabinetWorkItem); | 123 | var created = this.CreateCabinet(cabinetWorkItem); |
| 123 | 124 | ||
| 124 | // Update the cabinet work item to report back what cabinets were created. | 125 | // Update the cabinet work item to report back what cabinets were created. |
| 125 | lock (this.completedCabinets) | 126 | if (created?.Any() == true) |
| 126 | { | 127 | { |
| 127 | this.completedCabinets.Add(new CompletedCabinetWorkItem(cabinetWorkItem.DiskId, created)); | 128 | lock (this.completedCabinets) |
| 129 | { | ||
| 130 | this.completedCabinets.Add(new CompletedCabinetWorkItem(cabinetWorkItem.DiskId, created)); | ||
| 131 | } | ||
| 128 | } | 132 | } |
| 129 | } | 133 | } |
| 130 | } | 134 | } |
| @@ -186,22 +190,40 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 186 | // create the cabinet file | 190 | // create the cabinet file |
| 187 | var cabinetPath = Path.GetFullPath(cabinetWorkItem.CabinetFile); | 191 | var cabinetPath = Path.GetFullPath(cabinetWorkItem.CabinetFile); |
| 188 | var cab = new Cabinet(cabinetPath); | 192 | var cab = new Cabinet(cabinetPath); |
| 189 | var created = cab.Compress(compressFiles, cabinetWorkItem.CompressionLevel, maxCabinetSize, cabinetWorkItem.MaxThreshold); | ||
| 190 | 193 | ||
| 191 | // Best effort check to see if the cabinet is too large for the Windows Installer. | ||
| 192 | try | 194 | try |
| 193 | { | 195 | { |
| 194 | var fi = new FileInfo(cabinetPath); | 196 | var created = cab.Compress(compressFiles, cabinetWorkItem.CompressionLevel, maxCabinetSize, cabinetWorkItem.MaxThreshold); |
| 195 | if (fi.Length > Int32.MaxValue) | 197 | |
| 198 | // Best effort check to see if the cabinet is too large for the Windows Installer. | ||
| 199 | try | ||
| 196 | { | 200 | { |
| 197 | this.Messaging.Write(WarningMessages.WindowsInstallerFileTooLarge(cabinetWorkItem.SourceLineNumber, cabinetPath, "cabinet")); | 201 | var fi = new FileInfo(cabinetPath); |
| 202 | if (fi.Length > Int32.MaxValue) | ||
| 203 | { | ||
| 204 | this.Messaging.Write(WarningMessages.WindowsInstallerFileTooLarge(cabinetWorkItem.SourceLineNumber, cabinetPath, "cabinet")); | ||
| 205 | } | ||
| 198 | } | 206 | } |
| 207 | catch | ||
| 208 | { | ||
| 209 | } | ||
| 210 | |||
| 211 | return created; | ||
| 199 | } | 212 | } |
| 200 | catch | 213 | catch (Exception e) when (e.InnerException is Win32Exception win32Exception) |
| 201 | { | 214 | { |
| 215 | switch (win32Exception.NativeErrorCode) | ||
| 216 | { | ||
| 217 | case 0x4005: | ||
| 218 | this.Messaging.Write(ErrorMessages.CreateCabAddFileFailed()); | ||
| 219 | return null; | ||
| 220 | case 0x0070: | ||
| 221 | this.Messaging.Write(ErrorMessages.CreateCabInsufficientDiskSpace()); | ||
| 222 | return null; | ||
| 223 | default: | ||
| 224 | throw; | ||
| 225 | } | ||
| 202 | } | 226 | } |
| 203 | |||
| 204 | return created; | ||
| 205 | } | 227 | } |
| 206 | } | 228 | } |
| 207 | } | 229 | } |
