DynamicBuildInfo 0.2.7-beta

This is a prerelease version of DynamicBuildInfo.
dotnet add package DynamicBuildInfo --version 0.2.7-beta
NuGet\Install-Package DynamicBuildInfo -Version 0.2.7-beta
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="DynamicBuildInfo" Version="0.2.7-beta">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DynamicBuildInfo --version 0.2.7-beta
#r "nuget: DynamicBuildInfo, 0.2.7-beta"
#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.
// Install DynamicBuildInfo as a Cake Addin
#addin nuget:?package=DynamicBuildInfo&version=0.2.7-beta&prerelease

// Install DynamicBuildInfo as a Cake Tool
#tool nuget:?package=DynamicBuildInfo&version=0.2.7-beta&prerelease

DynamicBuildInfo

Simple nuget package that generates a partial ThisAssembly class with build information.

All fields inside the ThisAssembly class are compile-time constants, meaning they can be used in a project's AssemblyInfo.cs file.

This allows using dynamic* information in the AssemblyInfo.cs file, such as the current year at build time. (I am sure it comes at no surprise that I created this package in early January)

(*dynamic in the sense that it is not hard-coded but calculated at build time)

Usage

Install the nuget package in your project.

All the generated fields are added to a partial class called ThisAssembly.

Use it in AssemblyInfo.cs like this:

public const string Copyright = $"(c) {ThisAssembly.BuildInfo.Properties.Year} YourCompany";

Or as an attribute:

[assembly: Copyright($"(c) {ThisAssembly.BuildInfo.Properties.Year} YourCompany")]

Available fields

The following fields are available:

  • Project.Properties.Year- the current year at build time

Add fields

You can add additional fields to the ThisAssembly.BuildInfo.Properties class by specifying them in the .csproject file.

For example:

<ItemGroup>
    <DynamicBuildInfoProperties Include="SomeGuid">
        <Summary>Some GUID</Summary>
        <Value>$([System.Guid]::NewGuid())</Value>
    </DynamicBuildInfoProperties>
</ItemGroup>

This will add a field called SomeGuid to the ThisAssembly.BuildInfo.Properties class.

Each field you want to add must be specified in a separate BuildInfoProperties item.

The Include attribute specifies the name of the field and the Summary attribute is added as a comment to the field.

The Value attribute specifies the value of the field. It can be a static value or a MSBuild expression; see also Property Functions

Further reading

This package is heavily inspired by the GitInfo and MSBuilder packages.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.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
0.2.7-beta 9,925 1/10/2023
0.2.5-beta 99 1/10/2023
0.2.3-beta 92 1/10/2023