LinkDotNet.BuildInformation 2.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LinkDotNet.BuildInformation --version 2.1.0
                    
NuGet\Install-Package LinkDotNet.BuildInformation -Version 2.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LinkDotNet.BuildInformation" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LinkDotNet.BuildInformation" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="LinkDotNet.BuildInformation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LinkDotNet.BuildInformation --version 2.1.0
                    
#r "nuget: LinkDotNet.BuildInformation, 2.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LinkDotNet.BuildInformation@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LinkDotNet.BuildInformation&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=LinkDotNet.BuildInformation&version=2.1.0
                    
Install as a Cake Tool

Incremental Build Information Generator

.NET Nuget GitHub tag

This project provides a simple and easy-to-use C# source generator that embeds build information, such as the build time, platform, warning level, and configuration, directly into your code. By using the BuildInformation class, you can quickly access and display these details.

Features

  • Embeds build date (in UTC) in your code
  • Embeds platform (AnyCPU, x86, x64, ...) information in your code
  • Embeds compiler warning level in your code
  • Embeds build configuration (e.g., Debug, Release) in your code
  • Embeds the assembly version and assembly file version in your code
  • Embeds the target framework moniker in your code
  • Embeds the nullability analysis level in your code
  • Embeds the deterministic build flag in your code
  • Embeds the project path where the generator is running in your code
  • Embeds the language and language version (like "C#" and "12.0")

Configuration

By default the created class is internal and is not under any namespace. This can be changed by adding the following to your project file:

<PropertyGroup>
    <UseRootNamespaceForBuildInformation>true</UseRootNamespaceForBuildInformation>
</PropertyGroup>

<ItemGroup>
    <CompilerVisibleProperty Include="UseRootNamespaceForBuildInformation" />
</ItemGroup>

This will use the root namespace of the project for the generated class. This is especially helpful if the generator is used in multiple projects, that might be visible to each other.

The AllowProjectDirectoryBuildOutput property is used to allow the generator to write the project directory into the generated class. This is disabled by default, as it might leak sensitive information.

<PropertyGroup>
    <AllowProjectDirectoryBuildOutput>true</AllowProjectDirectoryBuildOutput>
</PropertyGroup>

<ItemGroup>
    <CompilerVisibleProperty Include="AllowProjectDirectoryBuildOutput" />
</ItemGroup>

Usage

To use the BuildInformation class in your project, add the NuGet package:

dotnet add package LinkDotNet.BuildInformation

Here is some code how to use the class:

using System;

Console.WriteLine($"Build at: {BuildInformation.BuildAt}");
Console.WriteLine($"Platform: {BuildInformation.Platform}");
Console.WriteLine($"Warning level: {BuildInformation.WarningLevel}");
Console.WriteLine($"Configuration: {BuildInformation.Configuration}");
Console.WriteLine($"Assembly version: {BuildInformation.AssemblyVersion}");
Console.WriteLine($"Assembly file version: {BuildInformation.AssemblyFileVersion}");
Console.WriteLine($"Assembly name: {BuildInformation.AssemblyName}");
Console.WriteLine($"Assembly copyright: {BuildInformation.AssemblyCopyright}");
Console.WriteLine($"Assembly company: {BuildInformation.AssemblyCompany}");
Console.WriteLine($"Target framework moniker: {BuildInformation.TargetFrameworkMoniker}");
Console.WriteLine($"Analysis level: {BuildInformation.Nullability}");
Console.WriteLine($"Deterministic build: {BuildInformation.Deterministic}");
Console.WriteLine($"Analysis level: {BuildInformation.AnalysisLevel}");
Console.WriteLine($"Project directory: {BuildInformation.ProjectDirectory}");
Console.WriteLine($"Language: {BuildInformation.Language}");
Console.WriteLine($"Language version: {BuildInformation.LanguageVersion}");
Console.WriteLine($"Compiler version: {BuildInformation.CompilerVersion}");
Console.WriteLine($"DotNet SDK version: {BuildInformation.DotNetSdkVersion}");

You can also hover over the properties to get the currently held value (xmldoc support). An example output could look like this:

Build at: 08/12/2025 11:51:53
Platform: AnyCpu
Warning level: 8
Configuration: Release
Assembly version: 1.0
Assembly file version: 1.2
Assembly name: LinkDotNet.BuildInformation.Sample
Assembly copyright: LinkDotNet 2025
Assembly company: LinkDotNet
Target framework moniker: net8.0
Analysis level: Enable
Deterministic build: True
Analysis level: 8.0
Project directory: /Users/example/repo/this/Sample.csproj
Language: C#
Language version: 14.0
Compiler version: 5.0.0.0
DotNet SDK version: .NET 10.0.0

Contributing

If you would like to contribute to the project, please submit a pull request or open an issue on the project's GitHub page. We welcome any feedback, bug reports, or feature requests.

License

This project is licensed under the MIT License.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.2 766 12/9/2025
2.1.1 435 12/9/2025
2.1.0 426 12/8/2025
2.0.0 722 12/3/2025
1.3.0 6,604 10/11/2024
1.2.1 15,162 5/2/2024
1.2.0 2,244 4/25/2024
1.1.2 1,092 4/20/2024
1.1.1 205 4/19/2024
1.0.0 4,036 12/30/2023
0.4.2 6,114 8/29/2023
0.4.1 1,401 8/12/2023
0.4.0 1,230 6/15/2023
0.3.0 4,764 3/24/2023
0.1.0 1,427 3/24/2023