Repository navigation
Description
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:
- Accepts paths to two SDK tarballs built from the same source commit.
- Extracts both tarballs and compares their contents.
- Performs byte-level comparison of all files, identifying any files that differ between the two builds.
- Uses exclusion system to filter out known non-reproducible files.
- 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).
- 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:
-
Find the associated
dotnet-unified-buildrun. Use the same logic assdk-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.
-
Download the SDK tarball from the identified
dotnet-unified-buildrun using the existingdownload-vmr-artifact.ymltemplate. This becomes the "first build" tarball. -
Checkout the VMR at the same commit as the
dotnet-unified-buildrun. -
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.
-
Run the
ReproducibilityTestspassing both tarball paths.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]Define a reproducibility validation test for the SDK tarball[/-][+]Define a reproducibility validation test for the SDK[/+][-]Define a reproducibility validation test for the SDK[/-][+]Define a reproducibility validation test for the SDK tarball[/+]omajid commentedon May 14, 2026
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.
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:
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.