Skip to content

Commit

Permalink
PanelSwWix4: Support compression level for 7z containers
Browse files Browse the repository at this point in the history
  • Loading branch information
nirbar committed Sep 23, 2024
1 parent 15c4a90 commit 8e2362e
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/github-actions-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<Wix4Version Condition=" '$(Wix4Version)' == '' ">4.0.5</Wix4Version>
<PanelSwWix4Version Condition=" '$(PanelSwWix4Version)' == '' ">5.0.0-psw-wix.0299-55</PanelSwWix4Version>
<SevenZapVersion Condition=" '$(SevenZapVersion)' == '' ">24.8.40</SevenZapVersion>
<PanelSwWix4Version Condition=" '$(PanelSwWix4Version)' == '' ">5.0.0-psw-wix.0301-56</PanelSwWix4Version>
<SevenZapVersion Condition=" '$(SevenZapVersion)' == '' ">24.8.41</SevenZapVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="WixToolset.DUtil" version="$(Wix4Version)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<SubSystem>Windows</SubSystem>
<TargetMachine Condition="'$(Platform)' == 'x86'">MachineX86</TargetMachine>
<ModuleDefinitionFile>PanelSwBackendExtension.def</ModuleDefinitionFile>
<ImageHasSafeExceptionHandlers Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
24 changes: 20 additions & 4 deletions src/PanelSwWixExtension/PanelSwBurnContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class PanelSwBurnContainer : BaseBurnContainerExtension
{
public override IReadOnlyCollection<string> ContainerExtensionIds => new[] { PanelSwWixExtension.CONTAINER_EXTENSION_ID };

public override void CreateContainer(WixBundleContainerSymbol container, IEnumerable<WixBundlePayloadSymbol> containerPayloads, out string sha512, out long size)
public override void CreateContainer(WixBundleContainerSymbol container, IEnumerable<WixBundlePayloadSymbol> containerPayloads, WixToolset.Data.CompressionLevel? level, out string sha512, out long size)
{
sha512 = null;
size = 0;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -82,7 +82,7 @@ private void CreateContainerZip(WixBundleContainerSymbol container, IEnumerable<
}
}

private void CreateContainerLzma(WixBundleContainerSymbol container, IEnumerable<WixBundlePayloadSymbol> containerPayloads)
private void CreateContainerLzma(WixBundleContainerSymbol container, IEnumerable<WixBundlePayloadSymbol> containerPayloads, WixToolset.Data.CompressionLevel? level)
{
string xmlFile = null;
XmlDocument xmlDocument = null;
Expand Down Expand Up @@ -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))
{
Expand Down
2 changes: 1 addition & 1 deletion src/TidyBuild.custom.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)TidyBuild.user.props" Condition="Exists('$(MSBuildThisFileDirectory)TidyBuild.user.props')"/>
<PropertyGroup>
<FullVersion>3.19.2</FullVersion>
<FullVersion>3.20.0</FullVersion>
<FullVersion Condition=" '$(GITHUB_RUN_NUMBER)'!='' ">$(FullVersion).$(GITHUB_RUN_NUMBER)</FullVersion>
<ProductName>PanelSwWixExtension</ProductName>
<Manufacturer>Panel::Software</Manufacturer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<OutputType>Bundle</OutputType>
<DefaultCompressionLevel>Low</DefaultCompressionLevel>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\DeferredExePackage\DeferredExePackage.vcxproj"/>
Expand Down
5 changes: 3 additions & 2 deletions src/UnitTests/ContainerTemplateUT/ContainerTemplateUT.wxs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:PanelSW="http://schemas.panel-sw.co.il/wix/WixExtension">
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:PanelSW="http://schemas.panel-sw.co.il/wix/WixExtension"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.panel-sw.co.il/wix/WixExtension ../../PanelSwWixExtension/XSD/PanelSwWixExtension.xsd">
<Bundle Name="ContainerTemplateUT" Version="$(var.JetVersion)" Manufacturer="$(var.JetManufacturer)" UpgradeCode="f37b5c48-dd17-4ff6-af58-1bd697c2c1d7">
<BootstrapperApplication>
<WixStandardBootstrapperApplication Theme="rtfLicense" LicenseUrl="www.google.com" xmlns="http://wixtoolset.org/schemas/v4/wxs/bal"/>
</BootstrapperApplication>
<?if $(EnableZipContainer) ~= true?>
<PanelSW:ContainerTemplate DefaultType="attached" Compression="SevenZip" NameTemplate="$(TargetName).7z"/>
<PanelSW:ContainerTemplate DefaultType="detached" Compression="SevenZip" NameTemplate="$(TargetName)-{0}.7z"/>
<?else?>
<PanelSW:ContainerTemplate DefaultType="detached"/>
<?endif?>
Expand Down
2 changes: 1 addition & 1 deletion src/global.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 8e2362e

Please sign in to comment.