Skip to content

Define a reproducibility validation test for the SDK tarball #5486

Closed
dotnet/dotnet
#6622

Description

@mthalman

Summary

Add a test that validates the reproducibility of the .NET SDK tarball build by comparing the output of two builds of the same commit. The test asserts the two tarballs are identical (or differ only in known, baselined ways).

Background

The parent issue (#4963) tracks making .NET's build deterministic/reproducible. A key part of this effort is having a test that continuously validates reproducibility so regressions are caught. There is currently no test that validates byte-for-byte reproducibility of the build output.

Test Design

Test Location

The test should live in test/Microsoft.DotNet.Tests/ alongside existing VMR-level tests.

Test Class

Create a new ReproducibilityTests class that:

  1. Accepts paths to two SDK tarballs built from the same source commit.
  2. Extracts both tarballs and compares their contents.
  3. Performs byte-level comparison of all files, identifying any files that differ between the two builds.
  4. Uses exclusion system to filter out known non-reproducible files.
  5. Uses baseline comparison system to compare the list of differing files against a baseline. Any new non-reproducible file causes the test to fail; any file that becomes reproducible causes the baseline to be stale (and should be updated).
  6. Generates updated baseline/exclusion files in the logs directory so that CI can publish them for easy baseline maintenance.

Conditional Test Execution

The test should be conditional on both tarball paths being provided.

Pipeline Design

Obtaining the Two Builds

The priority right now is to test reproduceability for source-only builds so these will be the build types that are targeted for this workflow.

The test pipeline follows the same pattern as eng/pipelines/templates/jobs/sdk-diff-tests.yml to locate and download artifacts from a prior dotnet-unified-build run:

  1. Find the associated dotnet-unified-build run. Use the same logic as sdk-diff-tests.yml:

    • If triggered by a pipeline resource, use the triggering pipeline's run ID and commit SHA.
    • Otherwise, query for the latest completed run on the current branch.
  2. Download the SDK tarball from the identified dotnet-unified-build run using the existing download-vmr-artifact.yml template. This becomes the "first build" tarball.

  3. Checkout the VMR at the same commit as the dotnet-unified-build run.

  4. Run a second build of the SDK at that commit, producing a second SDK tarball. This build should use the same build flags/configuration as the original.

  5. Run the ReproducibilityTests passing both tarball paths.

Activity

  1. moved this from Backlog to 11.0 in .NET Source Buildon Feb 19, 2026
  2. added
    area-testing
    and removed on Feb 19, 2026
  3. self-assigned this
    on Apr 16, 2026
  4. changed the title [-]Define a reproducibility validation test for the SDK tarball[/-] [+]Define a reproducibility validation test for the SDK[/+] on Apr 18, 2026
  5. changed the title [-]Define a reproducibility validation test for the SDK[/-] [+]Define a reproducibility validation test for the SDK tarball[/+] on Apr 18, 2026
  6. omajid commented on May 14, 2026

    @omajid
    Member

    I have a local hacked up version of this test, and I have been thinking about how to meet a minimum bar and how to evolve it. Some thoughts.

    Run a second build of the SDK at that commit, producing a second SDK tarball. This build should use the same build flags/configuration as the original.

    https://reproducible-builds.org/docs/getting-started/ suggests tackling reproduciblity in phases.

    For phase 1, I am focusing on local reproducibility: building using the same machine, the same user, the same build tools, the same environment, same build flags and same build paths. The only thing really changing is files getting recreated/updated (so we find all filesystem-order-dependent code) and wall-clock-time (so we find hardcoded timestamps). The end desire is that we should get two SDKs that are bit-by-bit identical in this scenario.

    For future phases we might want to remove one of these constraints, and add variations. For example:

    • Change dates more extensively (move system clock 48 hours?)
    • Change system language and locale settings
    • Build on two different machines (but same user name, same build paths, same build tools, etc)
    • Build by two different users (but keep the same machine, same build paths, same build tools, etc)
    • Change build paths

    Unfortunately, I can't see a practical scenario where changing the build tools (eg, clang) can still let us produce identical binaries. A minor version difference in clang might, for example, completely change how a function is optimized, throwing reproducibility out the window. A configuration like Profile-Guided-Optimization (enabled in the Microsoft build AFAIK but not in source-build) would be impossible to handle between two builds.

  7. moved this from 11.0 to In Progress in .NET Source Buildon May 28, 2026
  8. moved this from In Progress to Done in .NET Source Buildon Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-testing

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions