Building
How to build, test, pack, and publish every component of the repository.
Prerequisites
- .NET SDK 11.0 or later (the solution targets
net8.0,net9.0,net10.0, andnet11.0; the SDKβsrollForwardis set tolatestMajorwith prereleases allowed). - Works on Windows, Linux, and macOS.
- No native toolchains are required β the library is 100% managed.
Solution layout
CSharp_CHDSharp.sln
βββ CHDSharpLib/ The library (NuGet package: CHDSharp)
βββ CHDSharpCli/ Command-line CHD manager (binary: CHDSharp)
βββ CHDSharpLib/Encoder/ Encoder subsystem (V5 CHD creation; see [Encoder](encoder.md))
βββ CHDSharpTest/ xUnit unit + corpus tests
βββ CHDSharpTestDataGeneration/ Deterministic corpus generator
βββ CHDSharpTester/ WPF interactive tester
βββ CHDSharpEncoderTest/ xUnit encoder tests (456 tests)
βββ CHDSharpBattleTest/ Battle test harness (chdman vs CHDSharp)
βββ VendoredZLib/ Pure C# zlib port
βββ VendoredLZMA/ LZMA SDK C# port
βββ VendoredFlac/ Pure C# FLAC encoder/decoder
βββ VendoredZSTD/ Pure C# zstd 1.5.5 encoder/decoder (MAME parity)
βββ Directory.Build.props Centralized versioning (1.7.3) and analyzer setup
Build
# Everything (Debug)
dotnet build
# Release
dotnet build -c Release
# A single project
dotnet build CHDSharpLib/CHDSharpLib.csproj -c Release
Centralized versioning
Directory.Build.props defines a single <Version> (currently 1.7.3) that all projects inherit, so AssemblyVersion, FileVersion, and the NuGet package version stay in sync automatically.
Code style & analyzers
All projects enable:
Nullable+ImplicitUsings.LangVersion 15.- Meziantou.Analyzer (build-time analyzer,
PrivateAssets=all). CHDSharpLibadditionally treats missing XML documentation (CS1591) as an error, so all public API members must carry XML doc comments.
Code inspections
The solution is kept free of ReSharper warnings and errors. The gate runs InspectCode from
the JetBrains command-line tools
(jb), from the repository root:
# The four vendored codec projects are excluded outright: they are checked in verbatim
# and editing them for style would risk the byte-for-byte chdman parity guarantee.
jb inspectcode CSharp_CHDSharp.sln --severity=WARNING --exclude="Vendored*/**" --output=inspectcode.xml
The inspection policy lives in the root .editorconfig:
- The vendored codecs are excluded from InspectCode.
VendoredZLib,VendoredLZMA,VendoredFlacandVendoredZSTD(projects and sources) are third-party ports checked in verbatim; byte-for-bytechdmanparity depends on them staying untouched. They are skipped by--exclude="Vendored*/**"in CI and by.editorconfig, and must never be edited to satisfy an inspection. - Consumer-facing models are exempt from βnever usedβ inspections. Public library records
(
CHDSharpLib/Models), the JSON corpus manifest (CHDSharpTestDataGeneration/Models) and the WPF data models (CHDSharpTester/Models) expose members that are only read by callers, serializers or XAML bindings.
InspectCode 2026.2 logs internal
AssertionExceptions while its nullable-flow analyzer walks the vendored ZSTD sources. This is a bug in the analyzer, not a finding: the report is still empty, and the--exclude="Vendored*/**"switch also silences the console.
Test
# Run the full suite (all target frameworks)
dotnet test
# A single framework
dotnet test -f net11.0
# A specific test class
dotnet test --filter "FullyQualifiedName~CorpusTests"
# Verbose console output
dotnet test -v detailed
The suite contains 4,223 tests per target framework (unit + corpus) that run against 30 deterministic CHD fixtures covering V1βV5 and every codec. See Testing.
The companion encoder suite (CHDSharpEncoderTest, 456 tests) validates CHD creation against chdman.exe β including 100 MB+ raw/CD round-trips:
dotnet test CHDSharpEncoderTest/ --filter "FullyQualifiedName~LargeFileValidationTests"
Regenerating the corpus requires the vintage
chdman/hdcompbinaries inCHDSharpTest/chdman/:dotnet run --project CHDSharpTestDataGenerationThe generator is deterministic: regenerating produces byte-identical fixtures.
The battle harness (CHDSharpBattleTest) cross-checks the decoder and encoder against
chdman.exe (3,174/3,174 checks on the deterministic corpus; 3003/3003 on a real-world
scan of 56 CHDs), and can also scan any real-world CHD
folders via --real <dir>:
dotnet run --project CHDSharpBattleTest # repo-root chdman.exe auto-resolved
dotnet run --project CHDSharpBattleTest -- --real "D:\CHD Collection"
Pack (NuGet)
# Library package: CHDSharp.<version>.nupkg
dotnet pack CHDSharpLib/CHDSharpLib.csproj -c Release
# CLI .NET tool package: CHDSharp.Cli.<version>.nupkg
dotnet pack CHDSharpCli/CHDSharpCli.csproj -c Release
Both packages are written to their projectβs bin/Release/ directory.
The library package (CHDSharp.<version>.nupkg) includes:
- The library DLL for
net8.0,net9.0,net10.0, andnet11.0. - The README (this wikiβs sibling pages are referenced from it), the combined license file (
LICENSE.txt), and the package icon. - Embedded PDBs (
DebugType=embedded) and embedded SourceLink for debugging. - Deterministic, reproducible builds (
Deterministic=true,ContinuousIntegrationBuildon GitHub Actions).
The CLI package (CHDSharp.Cli.<version>.nupkg) is a DotnetTool package. It publishes the CLI for all four target frameworks under tools/<tfm>/any, includes the LICENSE, README and icon, and exposes the chdsharp command:
dotnet tool install --global CHDSharp.Cli
chdsharp help
dotnet tool uninstall --global CHDSharp.Cli
Test a locally packed tool without touching the global tool store. The temporary NuGet config clears the public sources so the install can only resolve the package from the local output:
cat > local-tool-nuget.config <<'EOF'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="local" value="./CHDSharpCli/bin/Release" />
</packageSources>
</configuration>
EOF
dotnet tool install --tool-path ./tool-test --configfile local-tool-nuget.config CHDSharp.Cli --version <version>
./tool-test/chdsharp help
Dependencies
| Package | Version | Purpose |
|---|---|---|
| Microsoft.Extensions.Logging.Abstractions | 11.0.0 (all TFMs) | Pluggable logging (optional) |
| System.IO.Hashing | 11.0.0 (all TFMs) | SHA1/MD5 hashing helpers |
| Microsoft.SourceLink.GitHub | 11.0.100 | SourceLink (build-time, PrivateAssets=all) |
The 11.0.0 packages target net10+, but ship netstandard2.0 assets, so the net8.0/net9.0
targets remain functional; their advisory TFM-support warnings are suppressed in
Directory.Build.props.
All codec dependencies are vendored in-repo as project references and bundled inside the package (the runtime NuGet dependencies are the optional Microsoft.Extensions.Logging.Abstractions logging abstraction and System.IO.Hashing):
| Project | Purpose |
|---|---|
VendoredZLib |
Pure C# zlib (deflate/inflate) |
VendoredLZMA |
Pure C# LZMA SDK port |
VendoredFlac |
Pure C# FLAC encoder/decoder (based on CUETools.Flake) |
VendoredZSTD |
Pure C# zstd 1.5.5 encoder/decoder (C-to-C# port of MAMEβs bundled tree) |
CHDSharpLib also declares InternalsVisibleTo for CHDSharpTest, CHDSharpTestDataGeneration and CHDSharpEncoderTest so the test projects can exercise internal members directly.
Publish the CLI (release bundles)
# Build every release bundle (win/linux/osx x x64/arm64) into CHDSharpLib/bin/Release/
pwsh scripts/package-release.ps1
# One platform, custom output
pwsh scripts/package-release.ps1 -Rids win-x64 -OutputPath dist
# Native formats: .zip on Windows, .tar.gz on Linux, .dmg on macOS
pwsh scripts/package-release.ps1 -Rids linux-x64,linux-arm64 -OutputPath dist
For every runtime identifier the script publishes the CLI as a framework-dependent
single-file binary (--self-contained false -p:PublishSingleFile=true β the .NET
runtime is not embedded), appends LICENSE.txt, README.md, README.txt and
WhatsNew.md, and writes the platform-native bundle: CHDSharp_<rid>_v<version>.zip on
Windows, .tar.gz on Linux and .dmg on macOS (the exact asset names the CLIβs built-in
update check looks up on GitHub releases, e.g. CHDSharp_linux-x64_v1.7.3.tar.gz).
Existing files in the output path are never deleted. macOS .dmg bundles must be built on
macOS. The binary is named CHDSharp (CHDSharp.exe on Windows); bundles require the
.NET 11 runtime.
The Release GitHub Actions workflow (.github/workflows/release.yml) runs this script
on a version tag with one native runner per platform, then attests and publishes all six
assets in a final release job, pushes the CHDSharp and CHDSharp.Cli NuGet packages, and
syncs the wiki β see CI.
Documentation site (Jekyll + DocFX)
The published site at https://purelogiccode.github.io/CHDSharp/ is the combination of two builds:
- the Jekyll guides in
docs/(dark theme, sidebar, and the same pages mirrored to the wiki), and - the DocFX API reference generated from
CHDSharpLibβs XML documentation, published under/api/.
# Guides only
gem install jekyll -v 4.3.4 --no-document
jekyll build --source docs --destination _site --strict_front_matter
# Complete site: guides + API reference, with the CHDSharp theme applied
pwsh scripts/build-api-docs.ps1
DocFX is pinned in .config/dotnet-tools.json, so dotnet tool restore installs exactly the
version CI uses. scripts/build-api-docs.ps1 runs docfx metadata, docfx build and appends
docfx/theme.css to the template stylesheet so the reference matches the guides. Generated
metadata (docfx/*.yml) and the rendered site (_site/) are git-ignored.
The Pages workflow (.github/workflows/pages.yml) builds both halves into one artifact and deploys
it with actions/deploy-pages. GitHub Pages uses build_type: workflow, so the wiki job no longer
requests a legacy Pages rebuild.
CI
The repository is set up for GitHub Actions (ContinuousIntegrationBuild=true), producing deterministic builds and SourceLink-enabled symbols.
ci.yml- the build + test gatekeeper, on every push tomain, every pull request, and manual dispatch. TheCI gatejob aggregates:build & testacross Ubuntu, macOS and Windows: builds the full solution on Windows and the cross-platform subset elsewhere with-warnaserror(NuGet audit covers direct and transitive packages), then runs both xUnit suites (CHDSharpTest- 4,223 tests per target framework - andCHDSharpEncoderTest- 456 tests) for all four TFMs.quality:jb inspectcode --severity=WARNING, failing on any finding and uploading SARIF to code scanning.package:dotnet packfor both NuGet packages, a.nupkglayout check for every target framework, and a smoke-install of the tool, uploaded as an artifact.coverage: merged Cobertura coverage for both suites onnet11.0(the wall-clock parallel-encode test is excluded because instrumentation invalidates its timing).docs build (Jekyll + DocFX): buildsdocs/with--strict_front_matter, then generates the DocFX API reference, so broken XML docs or a brokendocfx.jsonfail the gate.chdman parity (smoke): the quick battle harness against the checked-inCHDSharpTester/chdman.exe.Wiki sync(onmainonly, after the gate): mirrorsdocs/to the wiki. The site itself is deployed bypages.yml.
Test-spawned CLI runs are isolated from the production bug-report API via
CHDSHARP_NO_BUG_REPORTS=1/CHDSHARP_NO_TELEMETRY=1.codeql.yml- CodeQL C# analysis (security-extended) plus GitHub Actions analysis onmain, pull requests, and a weekly schedule.dependency-review.yml- fails pull requests that add moderate-or-higher vulnerable dependencies.scorecard.yml- OpenSSF Scorecard, published to the public API and code scanning.release.yml- the tag-triggered release pipeline: builds the six platform CLI bundles on native runners (Windows.zip, Linux.tar.gz, macOS.dmg), attests their provenance, creates the GitHub release, publishes theCHDSharpandCHDSharp.CliNuGet packages, and syncs this documentation to the wiki. See Publish the CLI.
Repository security settings (Dependabot alerts/security updates, secret scanning with push protection, private vulnerability reporting, read-only workflow permissions, and mandatory full-SHA action pinning) are described in SECURITY.md.