diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 36ab62ed..f2a5c4b8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -47,7 +47,7 @@ jobs:
uses: actions/checkout@v4
- name: Fetch all tags and branches
run: git fetch --prune --unshallow
- - uses: actions/setup-dotnet@v3.2.0
+ - uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: |
2.1.818
@@ -69,7 +69,7 @@ jobs:
verbosity: Diagnostic
cake-version: tool-manifest
- name: Upload Issues
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
if-no-files-found: warn
name: ${{ matrix.os }} Issues
@@ -77,7 +77,7 @@ jobs:
BuildArtifacts/report.html
BuildArtifacts/**/coverlet/*.xml
- name: Upload Packages
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
if-no-files-found: warn
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 44da82cf..42cf7598 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -34,7 +34,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- - uses: actions/setup-dotnet@v3.2.0
+ - uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: |
5.0.x
@@ -48,7 +48,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- uses: github/codeql-action/init@v2
+ uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -68,10 +68,10 @@ jobs:
COMPlus_DbgMiniDumpName: BuildArtifacts/coredump.dmp
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v2
+ uses: github/codeql-action/analyze@v3
- name: Upload CoreDump
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
if: failure()
with:
if-no-files-found: warn
diff --git a/global.json b/global.json
index 780e635c..789c7ae5 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "8.0.100",
+ "version": "8.0.101",
"rollForward": "latestFeature"
}
}
diff --git a/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj b/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj
index 423e7e91..f4f49de8 100644
--- a/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj
+++ b/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj
@@ -25,11 +25,11 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
-
-
-
+
+
+
runtime; build; native; contentfiles; analyzers
all
diff --git a/src/Cake.7zip.Tests/FluentBuilder/AddCommandBuilderTests.cs b/src/Cake.7zip.Tests/FluentBuilder/AddCommandBuilderTests.cs
index 5815e384..7a226368 100644
--- a/src/Cake.7zip.Tests/FluentBuilder/AddCommandBuilderTests.cs
+++ b/src/Cake.7zip.Tests/FluentBuilder/AddCommandBuilderTests.cs
@@ -179,6 +179,45 @@ public void Add_can_use_CompressionMethod()
actual.ShouldBe(expected);
}
+ [Fact]
+ public void Add_can_use_CompressionMethod_additional_options()
+ {
+ var fixture = new FluentBuilderFixture();
+ fixture.Context
+ .InAddMode()
+ .WithArchive(new FilePath("out.zip"))
+ .WithFiles(new FilePath("in.txt"))
+ .WithCompressionMethodDictionarySize(26)
+ .WithCompressionMethodSortFilesByType(true);
+
+ const string expected = @"a -md=26 -mqs=on ""out.zip"" ""in.txt""";
+
+ var actual = fixture.EvaluateArgs();
+
+ actual.ShouldBe(expected);
+ }
+
+ [Fact]
+ public void Add_can_use_CompressionMethod_additional_options2()
+ {
+ var fixture = new FluentBuilderFixture();
+ fixture.Context
+ .InAddMode()
+ .WithArchive(new FilePath("out.zip"))
+ .WithFiles(new FilePath("in.txt"))
+ .WithCompressionMethod(m =>
+ {
+ m.DictionarySize = 25; // 32MB
+ m.SortFilesByType = false;
+ });
+
+ const string expected = @"a -md=25 -mqs=off ""out.zip"" ""in.txt""";
+
+ var actual = fixture.EvaluateArgs();
+
+ actual.ShouldBe(expected);
+ }
+
[Fact]
public void Add_can_use_CompressionMethod_multiple_times()
{
@@ -557,4 +596,4 @@ public void Add_can_use_FullQualifiedPaths_without_driveletter()
actual.ShouldBe(expected);
}
-}
\ No newline at end of file
+}
diff --git a/src/Cake.7zip.Tests/FluentBuilder/SwitchCompressionMethodBuilderTests.cs b/src/Cake.7zip.Tests/FluentBuilder/SwitchCompressionMethodBuilderTests.cs
index 8ea7179a..7e7a35b1 100644
--- a/src/Cake.7zip.Tests/FluentBuilder/SwitchCompressionMethodBuilderTests.cs
+++ b/src/Cake.7zip.Tests/FluentBuilder/SwitchCompressionMethodBuilderTests.cs
@@ -49,4 +49,30 @@ public void WithCompressionMethodMethod_returns_the_builder()
actual.ShouldBe(expected.Object);
}
-}
\ No newline at end of file
+
+ [Fact]
+ public void WithCompressionMethodDictionarySize_returns_the_builder()
+ {
+ var expected = new Mock>();
+ var command = new Mock();
+ command.SetupProperty(c => c.CompressionMethod);
+ expected.Setup(x => x.Command).Returns(command.Object);
+
+ var actual = expected.Object.WithCompressionMethodDictionarySize(default!);
+
+ actual.ShouldBe(expected.Object);
+ }
+
+ [Fact]
+ public void WithCompressionMethodSortFilesByType_returns_the_builder()
+ {
+ var expected = new Mock>();
+ var command = new Mock();
+ command.SetupProperty(c => c.CompressionMethod);
+ expected.Setup(x => x.Command).Returns(command.Object);
+
+ var actual = expected.Object.WithCompressionMethodSortFilesByType(default!);
+
+ actual.ShouldBe(expected.Object);
+ }
+}
diff --git a/src/Cake.7zip.Tests/Settings/Switches/SwitchCompressionMethodTests.cs b/src/Cake.7zip.Tests/Settings/Switches/SwitchCompressionMethodTests.cs
index 6504c0b2..658f3376 100644
--- a/src/Cake.7zip.Tests/Settings/Switches/SwitchCompressionMethodTests.cs
+++ b/src/Cake.7zip.Tests/Settings/Switches/SwitchCompressionMethodTests.cs
@@ -39,6 +39,36 @@ public void CompressionMethod_method_works()
actual.ShouldBe(expected);
}
+ [Fact]
+ public void CompressionMethod_dictionarysize_works()
+ {
+ var fixture = new SevenZipSettingsFixture();
+ var sut = new SwitchCompressionMethod
+ {
+ DictionarySize = 24
+ };
+ const string expected = "-md=24";
+
+ var actual = fixture.Parse(b => sut.BuildArguments(ref b));
+
+ actual.ShouldBe(expected);
+ }
+
+ [Fact]
+ public void CompressionMethod_sortbyfiletype_works()
+ {
+ var fixture = new SevenZipSettingsFixture();
+ var sut = new SwitchCompressionMethod
+ {
+ SortFilesByType = true
+ };
+ const string expected = "-mqs=on";
+
+ var actual = fixture.Parse(b => sut.BuildArguments(ref b));
+
+ actual.ShouldBe(expected);
+ }
+
[Fact]
public void CompressionMethod_combining_method_and_level()
{
@@ -54,4 +84,22 @@ public void CompressionMethod_combining_method_and_level()
actual.ShouldBe(expected);
}
-}
\ No newline at end of file
+
+ [Fact]
+ public void CompressionMethod_combining_all_options()
+ {
+ var fixture = new SevenZipSettingsFixture();
+ var sut = new SwitchCompressionMethod
+ {
+ Level = 9,
+ Method = "Copy",
+ DictionarySize = 23,
+ SortFilesByType = false
+ };
+ const string expected = "-mx=9 -mm=Copy -md=23 -mqs=off";
+
+ var actual = fixture.Parse(b => sut.BuildArguments(ref b));
+
+ actual.ShouldBe(expected);
+ }
+}
diff --git a/src/Cake.7zip/Builder/SwitchCompressionMethodBuilder.cs b/src/Cake.7zip/Builder/SwitchCompressionMethodBuilder.cs
index dc5a1657..9a58ed32 100644
--- a/src/Cake.7zip/Builder/SwitchCompressionMethodBuilder.cs
+++ b/src/Cake.7zip/Builder/SwitchCompressionMethodBuilder.cs
@@ -55,4 +55,30 @@ public static T WithCompressionMethodLevel(this T @this, int level)
{
return @this.WithCompressionMethod(x => x.Level = level);
}
-}
\ No newline at end of file
+
+ ///
+ /// fluent setter for the method of .
+ ///
+ /// the builder to support the .
+ /// The this.
+ /// Size of the dictionary.
+ /// The builder-instance for fluent re-use.
+ public static T WithCompressionMethodDictionarySize(this T @this, int dictionarySize)
+ where T : ISupportSwitchBuilder
+ {
+ return @this.WithCompressionMethod(x => x.DictionarySize = dictionarySize);
+ }
+
+ ///
+ /// fluent setter for the method of .
+ ///
+ /// the builder to support the .
+ /// The this.
+ /// enable / disable the sorting files by type in solid archives.
+ /// The builder-instance for fluent re-use.
+ public static T WithCompressionMethodSortFilesByType(this T @this, bool sortFilesByType)
+ where T : ISupportSwitchBuilder
+ {
+ return @this.WithCompressionMethod(x => x.SortFilesByType = sortFilesByType);
+ }
+}
diff --git a/src/Cake.7zip/Switches/SwitchCompressionMethod.cs b/src/Cake.7zip/Switches/SwitchCompressionMethod.cs
index 389d591f..cde3bd2c 100644
--- a/src/Cake.7zip/Switches/SwitchCompressionMethod.cs
+++ b/src/Cake.7zip/Switches/SwitchCompressionMethod.cs
@@ -40,6 +40,26 @@ public class SwitchCompressionMethod : ISwitch
// TODO: Better use Enum or static Props instead of the free string?
public string? Method { private get; set; }
+ ///
+ /// Gets or sets the size of the dictionary.
+ ///
+ /// Dictionary size in bytes will be calculated as 2 ^ DictionarySize (24 -> 2 ^ 24 -> 16MB).
+ ///
+ ///
+ /// The size of the dictionary.
+ ///
+ public int? DictionarySize { get; set; }
+
+ ///
+ /// Gets or sets the sorting files by type in solid archives.
+ ///
+ /// The default mode is qs=off.
+ ///
+ ///
+ /// The size of the dictionary.
+ ///
+ public bool? SortFilesByType { get; set; }
+
///
public void BuildArguments(ref ProcessArgumentBuilder builder)
{
@@ -53,5 +73,15 @@ public void BuildArguments(ref ProcessArgumentBuilder builder)
{
builder.Append($"-mm={Method}");
}
+
+ if (DictionarySize.HasValue)
+ {
+ builder.Append($"-md={DictionarySize.Value}");
+ }
+
+ if (SortFilesByType.HasValue)
+ {
+ builder.Append($"-mqs={(SortFilesByType.Value ? "on" : "off")}");
+ }
}
-}
\ No newline at end of file
+}