I would like to manipulate one of our (unsigned) CAB files generated with CABWIZ by replacing a file in the cabinet. Currently I'm using Microsoft.Deployment.Compression.Cab.dll
for this task (extract all files, replace the target, re-create the cabinet), which works pretty well as long I don't enable compression.
cabInfo.Pack(workingFolder.FullName, true, CompressionLevel.None, null);
As soon as I enable compression, WM 6.5.3 won't install the CAB file anymore:
Installation of CABFILE was unsuccessful.
The original file generated by CABWIZ is compressed, so I know WCELOAD in WM can handle compressed files. I searched for configuration options for the Microsoft library, but didn't find any.
Is there a way to create a compressed CAB with the Microsoft library or are there any other libraries that could be used for this task? There are a lot of libraries to manipulate CAB files out there, but I couldn't find information about one the can create compressed CAB files compatible with WCELOAD.
Update: After some research I found that WCELOAD supports the MSZIP algorithm, whereas the Microsoft library uses LZX. So I'm searching for a library capable of creating compressed CAB files using the MSZIP algorithm.
The packer used by the Microsoft.Deployment.Compression.Cab.dll
is a managed wrapper around the system file cabinet.dll
which does support the MSZIP algorithm. As the MS-RL is no problem for my project, I downloaded the WIX sources and modified the CAB compression library like this:
public enum CompressionLevel
{
/// <summary>Do not compress files, only store.</summary>
None = 0,
/// <summary>Minimum compression; fastest.</summary>
Min = 1,
/// <summary>A compromize between speed and compression efficiency.</summary>
Normal = 6,
/// <summary>Maximum compression; slowest.</summary>
Max = 10,
/// <summary>Compress files using the MSZIP algorithm.</summary>
MsZip = 11
}
private static NativeMethods.FCI.TCOMP GetCompressionType(CompressionLevel compLevel)
{
if (compLevel == CompressionLevel.MsZip)
{
return NativeMethods.FCI.TCOMP.TYPE_MSZIP;
}
else
{
// existing code goes here
}
}
Compressed with the MSZIP algorithm, WCELOAD does install the generated CAB files without any problems.