Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cmdwtf/buildtimestampgenerator
A small .NET source generator that creates a class to describe when your project was built.
https://github.com/cmdwtf/buildtimestampgenerator
Last synced: 14 days ago
JSON representation
A small .NET source generator that creates a class to describe when your project was built.
- Host: GitHub
- URL: https://github.com/cmdwtf/buildtimestampgenerator
- Owner: cmdwtf
- License: 0bsd
- Created: 2022-01-27T15:15:10.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-07T17:50:18.000Z (21 days ago)
- Last Synced: 2025-01-07T18:39:12.886Z (21 days ago)
- Language: C#
- Size: 58.6 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![build status](https://img.shields.io/github/workflow/status/cmdwtf/BuildTimestampGenerator/.NET%20Build%20&%20NuGet%20Publish)](https://github.com/cmdwtf/BuildTimestampGenerator/actions/workflows/dotnet.yaml) [![nuget](https://img.shields.io/nuget/v/cmdwtf.BuildTimestampGenerator)](https://www.nuget.org/packages/cmdwtf.BuildTimestampGenerator) [![license: 0BSD](https://img.shields.io/badge/license-0BSD-green)](./LICENSE)
![icon](.meta/timestamp-icon.png#gh-dark-mode-only)
![icon](.meta/timestamp-icon-alt.png#gh-light-mode-only)# 🛠⏲ BuildTimestampGenerator
Have you wanted a way to reliably get the time your application was compiled at, but still wanted to have 'deterministic' builds enabled? Well then do I have the package for you!This is a small Roslyn source generator that outputs a class, `BuildTimestamp`, that contains several variables that describe when the source generator was run (and thus when your project was built.)
## âť“Usage
- Reference the source generator (sometimes called 'analyzer') in your `.csproj`, to [install it from NuGet](https://www.nuget.org/packages/cmdwtf.BuildTimestampGenerator):
```xml
```
- If you want to refrence the project on disk rather than the NuGet package,
see an example reference [here](https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview#code-try-4).
- Build once so packages are restored and source can be generated.
- Use the properties of the class `cmdwtf.BuildTimestamp` to determine your compile time!### âť—Example
#### đź“ĄSource
```csharp
using System;namespace HelloTimestamp
{
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine($"I was built at {cmdwtf.BuildTimestamp.BuildTime}");
}
}
}
```#### 📤Output
```
I was built at 1/27/2022 12:54:21 PM
```(Obviously, your output will vary.)
## đź“ť License
cmdwtf.BuildTimestampGenerator is [licensed](./LICENSE) under the Zero-Clause BSD License (SPDX-License-Identifier: 0BSD). If you're interested in cmdwtf.BuildTimestampGenerator under other terms, please contact the authors. cmdwtf.BuildTimestampGenerator may make use of several open source packages. Those packages are each covered by their own copyrights and licenses, which are available via the tooling you use to restore the packages when building. As well, some portions of code are distributed under terms of other licenses, which are designated in comments. See `copyright` for more details.Copyright © 2022 [Chris March Dailey](https://cmd.wtf)
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.