Skip to content

WIP: Set SOURCE_DATE_EPOCH env var during the build - #5256

Closed
akoeplinger wants to merge 1 commit into
mainfrom
deterministic-build-timestamp
Closed

akoeplinger wants to merge 1 commit into
mainfrom
deterministic-build-timestamp

Conversation

@akoeplinger

Copy link
Copy Markdown
Member

NuGet is adding support for deterministic builds (NuGet/Home#14785) to make .NET more reproducible for dotnet/source-build#4963

This is a WIP PR to check if setting the SOURCE_DATE_EPOCH env var (which is already supported by various other tools like clang) causes any issues right now.

@omajid

omajid commented May 15, 2026 •

Copy link
Copy Markdown
Member

We could think about merging this to support #6622

cc @mthalman

else
sourceDateEpoch=$(TZ=UTC date -ud "${build_date:0:4}-${build_date:4:2}-${build_date:6:2} 00:00:00" '+%s')
fi
sourceDateEpoch=$((sourceDateEpoch + build_revision))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, maybe export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) to base it on the timestamp of the last git commit?

mthalman added a commit to mthalman/dotnet that referenced this pull request May 26, 2026
…elineStartTime

System.PipelineStartTime is set per-job, not per-run, so parallel jobs
get different values. Build.BuildNumber (format YYYYMMDD.Revision) is
consistent across all stages and jobs in the same pipeline run. Parse
the date portion into Unix epoch seconds and add the revision offset,
matching the approach in dotnet#5256.

Co-authored-by: Copilot <[email protected]>
@akoeplinger

Copy link
Copy Markdown
Member Author

Superseded by #6622

@akoeplinger akoeplinger closed this Jun 2, 2026
@akoeplinger
akoeplinger deleted the deterministic-build-timestamp branch June 3, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants