RSCG – Pekspro.BuildInformationGenerator
| name | Pekspro.BuildInformationGenerator |
| nuget | https://www.nuget.org/packages/Pekspro.BuildInformationGenerator/ |
| link | https://github.com/pekspro/BuildInformationGenerator |
| author | pekspro |
adding git build information
This is how you can use Pekspro.BuildInformationGenerator .
The code that you start with is
<project sdk="Microsoft.NET.Sdk">
<propertygroup>
<outputtype>Exe</outputtype>
<targetframework>net8.0</targetframework>
<implicitusings>enable</implicitusings>
<nullable>enable</nullable>
</propertygroup>
<itemgroup>
<packagereference version="0.2.0" include="Pekspro.BuildInformationGenerator">
</packagereference>
<propertygroup>
<emitcompilergeneratedfiles>true</emitcompilergeneratedfiles>
<compilergeneratedfilesoutputpath>$(BaseIntermediateOutputPath)\GX</compilergeneratedfilesoutputpath>
</propertygroup>
</itemgroup>
The code that you will use is
using BuildInfo; Console.WriteLine(MyBuildInfo.Git.CommitId); Console.WriteLine(MyBuildInfo.Git.Branch); Console.WriteLine(MyBuildInfo.AssemblyVersionString);
using Pekspro.BuildInformationGenerator;
namespace BuildInfo;
[BuildInformation(AddBuildTime = true,
AddGitCommitId = true,
AddAssemblyVersion = true,
AddDotNetSdkVersion = true,
AddGitBranch = true,
AddLocalBuildTime= true,
AddOSVersion = true,
FakeIfDebug =false,
FakeIfRelease =false)]
partial class MyBuildInfo
{
}
The code that is generated is
//---------------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by the Pekspro.BuildInformationGenerator source generator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//---------------------------------------------------------------------------------------
namespace BuildInfo
{
/// <summary>
/// Build information.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Pekspro.BuildInformationGenerator","0.2.0")]
static partial class MyBuildInfo
{
/// <summary>
/// Build time: 2024-07-18 19:57:53
/// Value was taken from the system clock.
/// </summary>
public static readonly global::System.DateTime BuildTime = new global::System.DateTime(638569294731432248L,global::System.DateTimeKind.Utc);
/// <summary>
/// Local build time: 2024-07-18 22:57:53 (+03:00)
/// Value was taken from the system clock.
/// </summary>
public static readonly global::System.DateTimeOffset LocalBuildTime = new global::System.DateTimeOffset(638569402731432248L,new global::System.TimeSpan(108000000000));
/// <summary>
/// Build information related to git.
/// </summary>
static public partial class Git
{
/// <summary>
/// The commit id in git at the time of build.
/// Value was taken from the AssemblyInformationalVersion attribute.
/// </summary>
public const string CommitId = "51a6dd67bbe091af607870fd80a52ea54d249e47";
/// <summary>
/// The short commit id in git at the time of build.
/// Value was taken from the AssemblyInformationalVersion attribute.
/// </summary>
public const string ShortCommitId = "51a6dd67";
/// <summary>
/// The git branch used at build time.
/// Value was taken from the git branch command.
/// </summary>
public const string Branch = "278-httpsgithubcompeksprobuildinformationgenerator";
}
/// <summary>
/// Version of the assembly.
/// Value was taken from assembly version attribute.
/// </summary>
public const string AssemblyVersionString = "1.0.0.0";
/// <summary>
/// OS version of the building machine.
/// Value was taken from Environment.OSVersion.
/// </summary>
public const string OSVersion = "Microsoft Windows NT 6.2.9200.0";
/// <summary>
/// .NET SDK version used at build time.
/// Value was taken from the dotnet --version command.
/// </summary>
public const string DotNetSdkVersion = "8.0.303";
}
}
Code and pdf at
https://ignatandrei.github.io/RSCG_Examples/v2/docs/Pekspro.BuildInformationGenerator
Leave a Reply