Skip to content

Releases: santisq/PSCompression

v3.0.1

02 Jul 20:01

Choose a tag to compare

What's Changed

  • Acknowledge .NET limitation when appending to existing ZipArchive by @santisq in #44.
  • Added AssemblyLoadContext support for PowerShell 7 (.NET 8.0 or later) to resolve DLL hell by isolating module dependencies. PowerShell 5.1 (.NET Framework) users can't get around this issue due to lack of AssemblyLoadContext in that runtime. See #45 and #46 for details.

Full Changelog: v3.0.0...v3.0.1

v3.0.0

24 Jun 00:58
05fadcc

Choose a tag to compare

What's Changed

  • Added commands supporting several algorithms to compress and decompress strings:

    • ConvertFrom-BrotliString & ConvertTo-BrotliString (using to BrotliSharpLib)
    • ConvertFrom-DeflateString & ConvertTo-DeflateString (from CLR)
    • ConvertFrom-ZlibString & ConvertTo-ZlibString (custom implementation)
  • Added commands for .tar entry management with a reduced set of operations compared to zip entry management:

    • Get-TarEntry: Lists entries, serving as the main entry point for TarEntry cmdlets.
    • Get-TarEntryContent: Retrieves the content of a tar entry.
    • Expand-TarEntry: Extracts a tar entry to a file.
  • Added commands to compress files and folders into .tar archives and extract .tar archives with various compression algorithms:

    • Compress-TarArchive & Expand-TarArchive: Supported compression algorithms include gz, bz2, zst, lz, and none (no compression).
  • Removed commands:

    • Compress-GzipArchive & Expand-GzipArchive: These were deprecated as they only supported single-file compression, which is now better handled by the module’s .tar archive functionality. For a workaround to compress or decompress single files using gzip, see Example 2 in ConvertTo-GzipString, which demonstrates using:

      [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($path)) | ConvertFrom-GzipString

This update was made possible by the following projects. If you find them helpful, please consider starring their repositories:

Full Changelog: v2.1.0...v3.0.0

v2.1.0

10 Jan 22:52

Choose a tag to compare

What's Changed

  • Code improvements.

  • Instance methods .OpenRead() and .OpenWrite() moved from ZipEntryFile to ZipEntryBase.

  • Adds support to operate from input Stream. This means you can now:

    • List entries:

      PS ..\PSCompression> $uri = 'https://www.powershellgallery.com/api/v2/package/PSCompression'
      PS ..\PSCompression> Invoke-WebRequest $uri | Get-ZipEntry | Select-Object -First 5
      
      Directory: /
      
      Type                    LastWriteTime  CompressedSize            Size Name
      ----                    -------------  --------------            ---- ----
      Archive            11/6/2024 10:29 PM       227.00  B       785.00  B [Content_Types].xml
      Archive            11/6/2024 10:27 PM       516.00  B         2.50 KB PSCompression.Format.ps1xml
      Archive            11/6/2024 10:29 PM       598.00  B         1.58 KB PSCompression.nuspec
      Archive            11/6/2024 10:27 PM         1.66 KB         5.45 KB PSCompression.psd1
      
      Directory: /_rels/
      
      Type                    LastWriteTime  CompressedSize            Size Name
      ----                    -------------  --------------            ---- ----
      Archive            11/6/2024 10:29 PM       276.00  B       507.00  B .rels
    • Read their content:

      PS ..\PSCompression> $entry = Invoke-WebRequest $uri | Get-ZipEntry -Include *.psd1
      PS ..\PSCompression> $entry | Get-ZipEntryContent -Raw | Invoke-Expression
      
      Name                           Value
      ----                           -----
      FunctionsToExport              {}
      PowerShellVersion              5.1
      GUID                           c63aa90e-ae64-4ae1-b1c8-456e0d13967e
      FormatsToProcess               {PSCompression.Format.ps1xml}
      RootModule                     bin/netstandard2.0/PSCompression.dll
      Author                         Santiago Squarzon
      ModuleVersion                  2.0.10
      CompanyName                    Unknown
      PrivateData                    {[PSData, System.Collections.Hashtable]}
      Description                    Zip and GZip utilities for PowerShell!
      Copyright                      (c) Santiago Squarzon. All rights reserved.
      CmdletsToExport                {Get-ZipEntry, Get-ZipEntryContent, Set-ZipEntryContent, Remove-ZipEntry…}
      VariablesToExport              {}
      AliasesToExport                {gziptofile, gzipfromfile, gziptostring, gzipfromstring…}
      RequiredAssemblies             {System.IO.Compression, System.IO.Compression.FileSystem}
    • Extract them:

      PS ..\PSCompression> $file = $entry | Expand-ZipEntry -PassThru
      PS ..\PSCompression> $file
      
      Mode                 LastWriteTime         Length Name
      ----                 -------------         ------ ----
      -a---           11/6/2024 10:27 PM           5584 PSCompression.psd1
      
      PS ..\PSCompression> Get-Content $file.FullName -TotalCount 3
      #
      # Module manifest for module 'PSCompression'
      #

    Other operations are not supported and will throw an error:

    PS ..\PSCompression> $entry | Remove-ZipEntry
    Remove-ZipEntry: The operation is not supported for entries created from input Stream.

Full Changelog: v2.0.10...v2.1.0

v2.0.10

06 Nov 22:27
15cf8e4

Choose a tag to compare

What's Changed

  • Fix EncodingTransformation for Encoding and int instances wrapped in PSObject by @santisq in #37. Same issue as #34 but when Encoding and int instances are wrapped in PSObject:
$utf8 = [System.Text.Encoding]::UTF8 | Write-Output
Get-ZipEntry .\test.zip | Get-ZipEntryContent -Encoding $utf8

# Get-ZipEntryContent: Cannot process argument transformation on parameter 'Encoding'.
#                      Could not convert input 'System.Text.UTF8Encoding+UTF8EncodingSealed' to a valid Encoding object.

$utf8 = [System.Text.Encoding]::UTF8.CodePage | Write-Output
Get-ZipEntry .\test.zip | Get-ZipEntryContent -Encoding $utf8

# Get-ZipEntryContent: Cannot process argument transformation on parameter 'Encoding'.
#                      Could not convert input '65001' to a valid Encoding object.

Full Changelog: v2.0.9...v2.0.10

v2.0.9

06 Nov 21:22

Choose a tag to compare

What's Changed

  • Fix EncodingTransformation when passing a string wrapped in PSObject by @santisq in #35.
$utf8 = Write-Output utf8
Get-ZipEntry .\test.zip | Get-ZipEntryContent -Encoding $utf8

# Get-ZipEntryContent: Cannot process argument transformation on parameter 'Encoding'.
#                      Could not convert input 'utf8' to a valid Encoding object.

Full Changelog: v2.0.8...v2.0.9

v2.0.8

24 Oct 00:06
9b5d559

Choose a tag to compare

What's Changed

  • New-ZipEntry - Use file's .FullName if no -EntryPath is provided by @santisq in #33:
    • Makes -EntryPath no longer Mandatory on File ParameterSet. When no -EntryPath is specified the cmdlet will use the -SourcePath in it's normalized form.
    • Added Pester tests and updated docs to reflect this change.
    • Updated all docs Syntax section to properly reflect Mandatory parameters.

Full Changelog: v2.0.7...v2.0.8

v2.0.7

20 Aug 16:58

Choose a tag to compare

What's Changed

  • Updates build process by @santisq in #27

  • Updates to README and Documentation by @santisq in #29

  • Adds -Exclude Parameter to Compress-ZipArchive by @santisq in #31. This parameter allows to exclude items from source. For example, if you wanted to compress the path folder excluding any file having the .xyz extension and any folder named test (including all its child items), you could do:

    Compress-ZipArchive .\path -Destination myPath.zip -Exclude *.xyz, *\test\*

Full Changelog: v2.0.6...v2.0.7

v2.0.6

05 Jun 19:45

Choose a tag to compare

What's Changed

  • Fixed parameter names in Compress-ZipArchive documentation by @martincostello in #25
  • Update to CI pipeline to use codecov-action@v4
  • Fixed coverlet support for Linux runner tests

New Contributors

Full Changelog: v2.0.5...v2.0.6

v2.0.5

26 Feb 19:06

Choose a tag to compare

What's changed

  • Fixed a bug with CompressionRatio Property added in v2.0.4 showing zip file entries with 0 Length in InvariantCulture Format.

Full Changelog: v2.0.4...v2.0.5

v2.0.4

25 Feb 18:51

Choose a tag to compare

What's Changed

  • Added command Rename-ZipEntry by @santisq in #22.
  • Fixed a bug that would prevent using the cmdlets in a remote PSSession or in a different Runspace or with a PSDrive, details in #21.
    Thanks @mattcargile for submitting the issue.

Breaking Changes

  • ZipEntryBase Type:

    • Renamed Property EntryName to Name.
    • Renamed Property EntryRelativePath to RelativePath.
    • Renamed Property EntryType to Type.
    • Renamed Method RemoveEntry() to Remove().
  • ZipEntryFile Type:

    • Added Property Extension.
    • Added Property BaseName.
    • Added Property CompressionRatio.
  • ZipEntryDirectory Type:

    • .Name Property now reflects the directory entries name instead of an empty string.
  • NormalizePath Method:

    • Moved from [PSCompression.ZipEntryExtensions]::NormalizePath to [PSCompression.Extensions.PathExtensions]::NormalizePath.
  • Get-ZipEntry command:

    • Renamed Parameter -EntryType to -Type.

Full Changelog: v2.0.3...v2.0.4