Build Info
Atom provides a pluggable system for determining the build's identity: its name, ID, version, and timestamp.
IBuildInfo
The IBuildInfo interface exposes the following parameters. Each can be overridden on the command line (e.g.
--build-name, --build-id, --build-version, --build-timestamp, --build-slice):
| Property | Type | Description |
|---|---|---|
BuildName |
string |
Logical name of the build (defaults to the solution file or root directory) |
BuildId |
string |
Unique identifier for this build run |
BuildVersion |
SemVer |
Semantic version of the build |
BuildTimestamp |
long |
Build timestamp in Unix epoch seconds |
BuildSlice |
string? |
Optional identifier for a build variation in matrix jobs |
Providers
Each piece of build info is resolved by a dedicated provider interface:
| Interface | Default | Description |
|---|---|---|
IBuildIdProvider |
DefaultBuildIdProvider |
Combines the build version and timestamp (e.g. "1.2.3-1672531200") |
IBuildVersionProvider |
DefaultBuildVersionProvider |
Parses version properties from Directory.Build.props; falls back to 1.0.0 |
IBuildTimestampProvider |
DefaultBuildTimestampProvider |
Returns the current time as Unix epoch seconds |
Replacing a Provider
Register your own implementation in the DI container. For example, the GitVersion module replaces both the ID and version providers:
builder.Services
.AddSingleton<IBuildIdProvider, GitVersionBuildIdProvider>()
.AddSingleton<IBuildVersionProvider, GitVersionBuildVersionProvider>();
SetupBuildInfo Target
The built-in ISetupBuildInfo interface provides a SetupBuildInfo target that:
- Reads the build name, ID, version, and timestamp from the providers.
- Writes each as a workflow variable (
BuildName,BuildId,BuildVersion,BuildTimestamp). - Adds a "Run Information" section to the build report.
- Logs the values.
Most builds include SetupBuildInfo as a dependency of their first real target.
See SetupBuildInfo for details.