TimeWarp.Build.Tasks is an MSBuild tasks library that provides build-time automation for .NET projects. The library automatically injects git metadata (commit hash and timestamp) into your assemblies at build time, enabling better traceability and versioning in production deployments.
This build-time dependency integrates seamlessly into your build pipeline without adding runtime overhead, making it ideal for CI/CD workflows and production builds where tracking exact source versions is critical.
If you find this project useful, please give it a star. Thanks!
- Automatic Git Metadata Injection - Embeds commit hash and timestamp into assembly metadata
- Build-Time Only - No runtime dependencies or performance impact
- Transitive Support - Automatically applied to projects that reference packages using this library
- Configurable - Can be disabled per-project with
TimeWarpEnableGitMetadata=false
- Fallback Handling - Gracefully handles non-git repositories without breaking builds
dotnet add package TimeWarp.Build.Tasks
Check out the latest NuGet packages on the TimeWarp Enterprises NuGet page.
Once installed, git metadata is automatically injected into your assemblies during build. Access the metadata at runtime:
using System.Reflection;
var assembly = typeof(Program).Assembly;
var commitHash = assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
.FirstOrDefault(a => a.Key == "CommitHash")?.Value;
var commitDate = assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
.FirstOrDefault(a => a.Key == "CommitDate")?.Value;
Console.WriteLine($"Built from commit: {commitHash}");
Console.WriteLine($"Commit date: {commitDate}");
To disable automatic git metadata injection for a specific project:
<PropertyGroup>
<TimeWarpEnableGitMetadata>false</TimeWarpEnableGitMetadata>
</PropertyGroup>
See full documentation.
This project is licensed under the Unlicense.
Your contributions are welcome! Before starting any work, please open a discussion.
Help with the documentation is also greatly appreciated.
If you have an issue and don't receive a timely response, feel free to reach out on our Discord server.