---
title: Get build info
summary: Read an optional build/version metadata file from a directory and return its contents as key/value pairs.
status: draft
owner: andmil
last_reviewed: 2026-09-15
library: SAIF.Web.API.Core
reference_type: package
operation_id: OP-CORE-001
trigger: Called by a consumer application (no in-repo caller found)
---

# Get build info

`BuildInfo.GetBuildInfo` is a standalone static utility that reads an optional `version*.dat`-pattern file from a caller-supplied directory and returns build/version metadata as key/value pairs, tolerating the file's absence. No caller of this method was found within this project or within `SAIF.Web.API.Clients`'s scanned source; it may be invoked by a hosting application (e.g., a diagnostics/health endpoint) outside this repository's scanned scope*.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-CORE-001 |
| **Trigger** | Called by a consumer (no in-repo caller found)* |
| **Inputs** | `appDirectory` (directory path to search), optional `buildInfoFilePattern` (glob, defaults to `version*.dat`) |
| **Outputs** | `IEnumerable<KeyValuePair<string,string>>` — a list of key/value metadata pairs |
| **Primary components** | `SAIF.Web.API.Core.BuildInfo.GetBuildInfo(string, string)` |
| **Entry point** | `src/SAIF.Web.API.Core/BuildInfo.cs` |

## Steps

1. Capture the calling assembly via `System.Reflection.Assembly.GetCallingAssembly()`. No business rule enforced; no SQL/table interaction; no delegation.
2. Search `appDirectory` for the first file matching `buildInfoFilePattern` using `System.IO.Directory.GetFiles(...).FirstOrDefault()`. No business rule enforced (file absence is tolerated, not an error — see step 4).
3. Seed the result list with two fixed entries: `"Assembly"` → the calling assembly's `FullName`, and `"Directory"` → the `appDirectory` argument as passed.
4. **If** no matching file was found (`file == null`): skip file parsing entirely and return only the two seeded entries from step 3. This is a silent/no-error fallback, not an exception path.
5. **If** a file was found: read all lines via `System.IO.File.ReadAllLines(file)`, then for each line apply the regex `(?<key>\w+): (?<value>.*)`.
   - Lines that match contribute a new key/value pair to the result.
   - Lines that do not match are silently skipped — no error, no logging.
   - This is free-form parsing of an externally-supplied version/build metadata file with no validation of key uniqueness or value format.
6. Return the accumulated `List<KeyValuePair<string,string>>` (typed as `IEnumerable<KeyValuePair<string,string>>`).

No step in this operation delegates to another documented library operation; only BCL I/O, reflection, and regex APIs are used.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([GetBuildInfo called]) --> Capture[Capture calling assembly]
	Capture --> Search["Search appDirectory for<br>buildInfoFilePattern"]
	Search --> Seed["Seed result with<br>Assembly and Directory<br>entries"]
	Seed --> Found{File found?}
	Found -->|No| ReturnSeeded(["Return seeded entries<br>only"])
	Found -->|Yes| ReadLines[Read all lines from file]
	ReadLines --> MatchLoop["Match each line against<br>key: value regex"]
	MatchLoop --> ReturnAll(["Return seeded + matched<br>key/value pairs"])
```

## Failure and edge-case behavior
- Missing build-info file: tolerated, not an error — only the seeded `Assembly`/`Directory` entries are returned.
- Non-matching lines in a found file: silently skipped, no error or logging.
- No validation of key uniqueness or value format is performed on parsed entries.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts.

## Sources
- `src/SAIF.Web.API.Core/BuildInfo.cs`
