Skip to content

Commit

Permalink
Add informational verbose logging for cab creation failures in the bo…
Browse files Browse the repository at this point in the history
…otstrapper
  • Loading branch information
nirbar committed Sep 5, 2024
1 parent 6556b32 commit 9c2cbd4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
38 changes: 26 additions & 12 deletions src/tools/wix/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4411,24 +4411,38 @@ private void CreateContainer(ContainerInfo container, string manifestFile)
++payloadCount;
}

using (WixCreateCab cab = new WixCreateCab(Path.GetFileName(container.TempPath), Path.GetDirectoryName(container.TempPath), payloadCount, 0, 0, this.defaultCompressionLevel))
try
{
// If a manifest was provided always add it as "payload 0" to the container.
if (!String.IsNullOrEmpty(manifestFile))
using (WixCreateCab cab = new WixCreateCab(Path.GetFileName(container.TempPath), Path.GetDirectoryName(container.TempPath), payloadCount, 0, 0, this.defaultCompressionLevel))
{
cab.AddFile(manifestFile, "0");
}
// If a manifest was provided always add it as "payload 0" to the container.
if (!String.IsNullOrEmpty(manifestFile))
{
cab.AddFile(manifestFile, "0");
}

foreach (PayloadInfoRow payload in container.Payloads)
{
ThrowIfCanceled();
Debug.Assert(PackagingType.Embedded == payload.Packaging);
this.core.OnMessage(WixVerboses.LoadingPayload(payload.FullFileName));
cab.AddFile(payload.FullFileName, payload.EmbeddedId);
}

foreach (PayloadInfoRow payload in container.Payloads)
{
ThrowIfCanceled();
Debug.Assert(PackagingType.Embedded == payload.Packaging);
this.core.OnMessage(WixVerboses.LoadingPayload(payload.FullFileName));
cab.AddFile(payload.FullFileName, payload.EmbeddedId);
cab.Complete();
}
}
catch (WixException)
{
long uncompressedSize = container.Payloads.Sum(p => p.FileSize);

ThrowIfCanceled();
cab.Complete();
this.core.OnMessage(WixVerboses.CabinetFailureInfo(null, container.Name, container.Payloads.Count, this.defaultCompressionLevel.ToString(), uncompressedSize, 0));
foreach (PayloadInfoRow payloadRow in container.Payloads)
{
this.core.OnMessage(WixVerboses.CabinetFailureFileInfo(payloadRow.SourceLineNumbers, payloadRow.Id, payloadRow.SourceFile, payloadRow.FileSize));
}
throw;
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/tools/wix/CabinetBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ private void ProcessWorkItems()
this.OnMessage(we.Error);
if (cabinetWorkItem != null)
{
this.OnMessage(WixVerboses.CabinetFailureInfo(null, cabinetWorkItem.CabinetFile, cabinetWorkItem.FileRows.Count, cabinetWorkItem.CompressionLevel.ToString(), cabinetWorkItem.MaxThreshold));
long uncompressedSize = 0;
foreach (FileRow fileRow in cabinetWorkItem.FileRows)
{
uncompressedSize += fileRow.FileSize;
}

this.OnMessage(WixVerboses.CabinetFailureInfo(null, cabinetWorkItem.CabinetFile, cabinetWorkItem.FileRows.Count, cabinetWorkItem.CompressionLevel.ToString(), uncompressedSize, cabinetWorkItem.MaxThreshold));
foreach (FileRow fileRow in cabinetWorkItem.FileRows)
{
this.OnMessage(WixVerboses.CabinetFailureFileInfo(fileRow.SourceLineNumbers, fileRow.File, fileRow.Source, fileRow.FileSize));
Expand Down
3 changes: 2 additions & 1 deletion src/tools/wix/Data/messages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4084,10 +4084,11 @@
</Message>
<Message Id="CabinetFailureInfo" Number="9037">
<Instance>
Additional info on cab creation failure: cabinet '{0}', file count {1}, compression level '{2}', max threshold {3}.
Additional info on cab creation failure: cabinet '{0}', file count {1}, compression level '{2}', uncompressed size {3}, max threshold {4}.
<Parameter Type="System.String" Name="cabinet" />
<Parameter Type="System.Int32" Name="fileCount" />
<Parameter Type="System.String" Name="compressionLevel" />
<Parameter Type="System.Int64" Name="uncompressedSize" />
<Parameter Type="System.Int32" Name="maxThreshold" />
</Instance>
</Message>
Expand Down

0 comments on commit 9c2cbd4

Please sign in to comment.