Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pekspro/BuildInformationGenerator
Simplifies the process of adding build information to your .NET projects, build time, commit ID, branch etc with a source generator
https://github.com/pekspro/BuildInformationGenerator
Last synced: about 1 month ago
JSON representation
Simplifies the process of adding build information to your .NET projects, build time, commit ID, branch etc with a source generator
- Host: GitHub
- URL: https://github.com/pekspro/BuildInformationGenerator
- Owner: pekspro
- License: mit
- Created: 2024-06-18T18:24:43.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-27T19:18:15.000Z (5 months ago)
- Last Synced: 2024-10-29T00:19:16.562Z (about 1 month ago)
- Language: C#
- Size: 83 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-NuGet.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- RSCG_Examples - https://github.com/pekspro/BuildInformationGenerator
README
This project simplifies the process of adding build information to your .NET projects. It uses a source generator to embed details like build time, commit ID and branch directly into your code.
By default, the values are faked in debug mode. This can be changed in the `[BuildInformation]` attribute with the `FakeIfDebug` property.
## Usage
Create a new partial class in your project and add the `[BuildInformation]` (from the `Pekspro.BuildInformationGenerator` namespace) attribute and define which information you want. For example:
```csharp
[BuildInformation(AddBuildTime = true, AddGitCommitId = true)]
partial class MyBuildInformation
{}
```Constants will automatically be added to this class that you can use like this:
```csharp
Console.WriteLine($"Build time: {MyBuildInformation.BuildTime}");
Console.WriteLine($"Commit id: {MyBuildInformation.Git.CommitId}");
```## Installation
Add the package to your application with:
```bash
dotnet add package Pekspro.BuildInformationGenerator
```This adds a `` to your project. It's recommended that you also add the attributes `PrivateAssets` and `ExcludeAssets` like below to exclude the source generator to your final assembly:
```xml
Exe
net8.0
```
Setting `PrivateAssets="all"` means any projects referencing this one won't get a reference to the _Pekspro.BuildInformationGenerator_ package.
Setting `ExcludeAssets="runtime"` ensures the _Pekspro.BuildInformationGenerator.Attributes.dll_ file is not copied to your build output (it is not required at runtime).
## Links
You can find more information and can report issues on [GitHub](https://github.com/pekspro/BuildInformationGenerator).