From 8e2362eb492702fc16e69fbfd1d1e8a4d5f97bbd Mon Sep 17 00:00:00 2001 From: Nir Bar Date: Mon, 23 Sep 2024 17:38:10 +0300 Subject: [PATCH] PanelSwWix4: Support compression level for 7z containers --- .github/workflows/github-actions-build.yml | 4 ++-- src/Directory.Packages.props | 4 ++-- .../PanelSwBackendExtension.vcxproj | 1 + .../PanelSwBurnContainer.cs | 24 +++++++++++++++---- src/TidyBuild.custom.props | 2 +- .../ContainerTemplateUT.wixproj | 1 + .../ContainerTemplateUT.wxs | 5 ++-- src/global.json | 2 +- 8 files changed, 31 insertions(+), 12 deletions(-) diff --git a/.github/workflows/github-actions-build.yml b/.github/workflows/github-actions-build.yml index 3662446..5c8937d 100644 --- a/.github/workflows/github-actions-build.yml +++ b/.github/workflows/github-actions-build.yml @@ -11,7 +11,7 @@ on: psw_wix_version: description: 'PanelSwWix4 version' required: true - default: 5.0.0-psw-wix.0299-55 + default: 5.0.0-psw-wix.0301-56 type: string jobs: @@ -37,7 +37,7 @@ jobs: Add-Content -Path ${{ github.env }} -Value "PSW_WIX_VERSION=${{ env.DEFAULT_PSW_WIX_VERSION }}" } env: - DEFAULT_PSW_WIX_VERSION: '5.0.0-psw-wix.0299-55' + DEFAULT_PSW_WIX_VERSION: '5.0.0-psw-wix.0301-56' - name: Prepare for build run: | diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index f3b3e0d..76fb24f 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -2,8 +2,8 @@ true 4.0.5 - 5.0.0-psw-wix.0299-55 - 24.8.40 + 5.0.0-psw-wix.0301-56 + 24.8.41 diff --git a/src/PanelSwBackendExtension/PanelSwBackendExtension.vcxproj b/src/PanelSwBackendExtension/PanelSwBackendExtension.vcxproj index 1a07e20..ea217cb 100644 --- a/src/PanelSwBackendExtension/PanelSwBackendExtension.vcxproj +++ b/src/PanelSwBackendExtension/PanelSwBackendExtension.vcxproj @@ -48,6 +48,7 @@ Windows MachineX86 PanelSwBackendExtension.def + false diff --git a/src/PanelSwWixExtension/PanelSwBurnContainer.cs b/src/PanelSwWixExtension/PanelSwBurnContainer.cs index c50dbcc..41164fd 100644 --- a/src/PanelSwWixExtension/PanelSwBurnContainer.cs +++ b/src/PanelSwWixExtension/PanelSwBurnContainer.cs @@ -16,7 +16,7 @@ public class PanelSwBurnContainer : BaseBurnContainerExtension { public override IReadOnlyCollection ContainerExtensionIds => new[] { PanelSwWixExtension.CONTAINER_EXTENSION_ID }; - public override void CreateContainer(WixBundleContainerSymbol container, IEnumerable containerPayloads, out string sha512, out long size) + public override void CreateContainer(WixBundleContainerSymbol container, IEnumerable containerPayloads, WixToolset.Data.CompressionLevel? level, out string sha512, out long size) { sha512 = null; size = 0; @@ -48,7 +48,7 @@ public override void CreateContainer(WixBundleContainerSymbol container, IEnumer CreateContainerZip(container, containerPayloads); break; case PSW_ContainerTemplate.ContainerCompressionType.SevenZip: - CreateContainerLzma(container, containerPayloads); + CreateContainerLzma(container, containerPayloads, level); break; } CalculateHashAndSize(container.WorkingPath, out sha512, out size); @@ -82,7 +82,7 @@ private void CreateContainerZip(WixBundleContainerSymbol container, IEnumerable< } } - private void CreateContainerLzma(WixBundleContainerSymbol container, IEnumerable containerPayloads) + private void CreateContainerLzma(WixBundleContainerSymbol container, IEnumerable containerPayloads, WixToolset.Data.CompressionLevel? level) { string xmlFile = null; XmlDocument xmlDocument = null; @@ -131,7 +131,23 @@ private void CreateContainerLzma(WixBundleContainerSymbol container, IEnumerable entries.Add(new SevenZap.SevenZap.FileEntry { EntryName = PanelSwWixExtension.CONTAINER_EXTENSION_ID, FullPath = xmlFile }); } - SevenZap.SevenZap.UpdateArchive(container.WorkingPath, entries, Context.CancellationToken); + // Compression level + SevenZap.SevenZap.CompressionLevel level7z = SevenZap.SevenZap.CompressionLevel.X5_Medium; + switch (level) + { + case WixToolset.Data.CompressionLevel.None: + case WixToolset.Data.CompressionLevel.Low: + level7z = SevenZap.SevenZap.CompressionLevel.X1_Fastest; + break; + case WixToolset.Data.CompressionLevel.Medium: + level7z = SevenZap.SevenZap.CompressionLevel.X5_Medium; + break; + case WixToolset.Data.CompressionLevel.High: + level7z = SevenZap.SevenZap.CompressionLevel.X9_Smallest; + break; + } + + SevenZap.SevenZap.UpdateArchive(container.WorkingPath, entries, Context.CancellationToken, level7z); if (!string.IsNullOrEmpty(xmlFile)) { diff --git a/src/TidyBuild.custom.props b/src/TidyBuild.custom.props index ae076e2..2d96dff 100644 --- a/src/TidyBuild.custom.props +++ b/src/TidyBuild.custom.props @@ -2,7 +2,7 @@ - 3.19.2 + 3.20.0 $(FullVersion).$(GITHUB_RUN_NUMBER) PanelSwWixExtension Panel::Software diff --git a/src/UnitTests/ContainerTemplateUT/ContainerTemplateUT.wixproj b/src/UnitTests/ContainerTemplateUT/ContainerTemplateUT.wixproj index 1b2f9f5..baa2c20 100644 --- a/src/UnitTests/ContainerTemplateUT/ContainerTemplateUT.wixproj +++ b/src/UnitTests/ContainerTemplateUT/ContainerTemplateUT.wixproj @@ -6,6 +6,7 @@ Release Bundle + Low diff --git a/src/UnitTests/ContainerTemplateUT/ContainerTemplateUT.wxs b/src/UnitTests/ContainerTemplateUT/ContainerTemplateUT.wxs index d782a88..5c3a558 100644 --- a/src/UnitTests/ContainerTemplateUT/ContainerTemplateUT.wxs +++ b/src/UnitTests/ContainerTemplateUT/ContainerTemplateUT.wxs @@ -1,10 +1,11 @@ - + - + diff --git a/src/global.json b/src/global.json index 7aecdd8..b28a17f 100644 --- a/src/global.json +++ b/src/global.json @@ -1,7 +1,7 @@ { "msbuild-sdks": { "WixToolset.Sdk": "4.0.5", - "PanelSwWix4.Sdk": "5.0.0-psw-wix.0299-55", + "PanelSwWix4.Sdk": "5.0.0-psw-wix.0301-56", "Microsoft.Build.Traversal": "4.0.0" } }