RSCG – AssemblyMetadata
| name | AssemblyMetadata |
| nuget | https://www.nuget.org/packages/AssemblyMetadata/ |
| link | https://github.com/BenjaminAbt/AssemblyMetadata |
| author | Benjamin Abt |
Generates compile-time assembly metadata constants (build date, year, time, etc.) — access build info as typed properties without runtime reflection.
How to use
1. Add the package as an Analyzer (no runtime reference needed):
“`xml
OutputItemType=”Analyzer” ReferenceOutputAssembly=”false” />
“`
2. Use the generated AssemblyMetadataInfo class directly:
“`csharp
Console.WriteLine(BenjaminAbt.AssemblyMetadata.AssemblyMetadataInfo.BuildInfo.BuildDateYear);
“`
You can use for Embedding build date/time metadata into assemblies as compile-time constants — useful for version screens, diagnostics, or ‘built on’ display info without runtime I/O or reflection.
This is how you can use AssemblyMetadata .
The code that you start with is
<project sdk="Microsoft.NET.Sdk">
<propertygroup>
<outputtype>Exe</outputtype>
<targetframework>net10.0</targetframework>
<implicitusings>enable</implicitusings>
<nullable>enable</nullable>
</propertygroup>
<itemgroup>
<packagereference version="2.0.16" include="AssemblyMetadata" referenceoutputassembly="false" outputitemtype="Analyzer">
</packagereference>
<propertygroup>
<emitcompilergeneratedfiles>true</emitcompilergeneratedfiles>
<compilergeneratedfilesoutputpath>$(BaseIntermediateOutputPath)\GX</compilergeneratedfilesoutputpath>
</propertygroup>
</itemgroup>
The code that you will use is
Console.WriteLine(BenjaminAbt.AssemblyMetadata.AssemblyMetadataInfo.BuildInfo.BuildDateYear);
The code that is generated is
// <auto-generated>
namespace BenjaminAbt.AssemblyMetadata
{
internal static class AssemblyMetadataInfo
{
/// <summary>Contains compile-time build metadata constants.</summary>
internal static class BuildInfo
{
/// <summary>Build time as UTC ISO 8601 string.</summary>
public const string BuildTimestamp = "2026-04-03T05:50:57.6130105+00:00";
/// <summary>Build time as Windows FileTime (100-ns intervals since 1601-01-01 UTC).</summary>
public const long BuildFileTimeUtc = 134196690576130105L;
/// <summary>Year component of the build date (UTC).</summary>
public const int BuildDateYear = 2026;
/// <summary>Month component of the build date (UTC).</summary>
public const int BuildDateMonth = 4;
/// <summary>Day component of the build date (UTC).</summary>
public const int BuildDateDay = 3;
/// <summary>Hour component of the build time (UTC, 24-hour).</summary>
public const int BuildTimeHour = 5;
/// <summary>Minute component of the build time (UTC).</summary>
public const int BuildTimeMinute = 50;
/// <summary>Second component of the build time (UTC).</summary>
public const int BuildTimeSecond = 57;
}
}
}
Code and pdf at
https://ignatandrei.github.io/RSCG_Examples/v2/docs/AssemblyMetadata