Skip to content

Replace Expand-Archive with System.IO.Compression.ZipFile for faster extraction #75

Description

Expand-Archive is implemented as PowerShell over the .NET zip APIs and is known to be substantially slower than calling the underlying API directly — especially for archives with many small entries, which is exactly the shape of Nerd Fonts zips (each archive contains dozens of .ttf/.otf variants).

For an Install-NerdFont -All run, extraction time is a meaningful fraction of total wall-clock time.

Request

Current experience

Expand-Archive -Path $downloadPath -DestinationPath $extractPath -Force

Each font archive takes noticeably longer to extract than its content size warrants. With ~70 archives in a full install, the overhead compounds.

Desired experience

Extraction uses the underlying .NET API directly, finishing in a fraction of the time with identical results on disk.

Acceptance criteria

  • Extracted files are byte-identical to those produced by Expand-Archive
  • -Force semantics are preserved (existing destination directory contents are overwritten)
  • Cross-platform behavior is preserved (Windows, Linux, macOS)
  • Extraction errors are surfaced with a clear message identifying the offending archive

Related


Technical decisions

API: Use [System.IO.Compression.ZipFile]::ExtractToDirectory from System.IO.Compression.FileSystem. The assembly is part of the .NET base in PowerShell 7, so no Add-Type is needed.

Overwrite behavior: Use the ExtractToDirectory(sourceArchiveFileName, destinationDirectoryName, overwriteFiles) overload (available in .NET Core 3.0+) to mirror Expand-Archive -Force.

Error path: Wrap the call in try { ... } catch { Write-Error ... ; continue } so a single corrupt archive does not stop a batch install.


Implementation plan

  • In src/functions/public/Install-NerdFont.ps1, replace the Expand-Archive call with [System.IO.Compression.ZipFile]::ExtractToDirectory($downloadPath, $extractPath, $true)
  • Ensure the destination directory exists or is created before extraction (the API requires the parent to exist)
  • Add error handling around the extraction call
  • Verify extraction parity (same files, same names, same content) on Windows and Linux runners

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions