Skip to content

Perpetual licensing never applies: BuildDateUtc in the published package contains a git error message #4665

Closed

Description

@clinder-its

Affected version: AutoMapper 16.2.0 (latest on NuGet), all target frameworks (net8.0, net9.0, net10.0, netstandard2.0, net471)

Description

Perpetual licensing relies on the assembly metadata BuildDateUtc (src/AutoMapper/Licensing/BuildInfo.cs). In the assemblies of the published NuGet package this value is not a date but the output of a failed git call: fatal: invalid --pretty format: cI.

Steps to reproduce

  1. Create a console app and add the package AutoMapper 16.2.0.

  2. Run:

    using System.Reflection;
    using AutoMapper;
    
    var value = typeof(IMapper).Assembly
        .GetCustomAttributes<AssemblyMetadataAttribute>()
        .First(a => a.Key == "BuildDateUtc")
        .Value;
    
    Console.WriteLine(value);                                 // fatal: invalid --pretty format: cI
    Console.WriteLine(DateTimeOffset.TryParse(value, out _)); // False

Expected: BuildDateUtc holds the commit date of the release and TryParse returns True.

Consequence

BuildInfo.BuildDate is null, so LicenseValidator never applies perpetual licensing. With a perpetual license, once the key has expired every start-up logs

  • Warning: Your license for the Lucky Penny software AutoMapper has the perpetual flag set, but the build date could not be determined. Perpetual licensing is unavailable.
  • Error: Your license for the Lucky Penny software AutoMapper expired N days ago.

although the package was built before the expiry of the license and should be covered by the perpetual license.

Cause (presumably)

The target EmbedBuildDate in src/AutoMapper/AutoMapper.csproj runs

<Exec Command="git log -1 --format=%25cI" ConsoleToMSBuild="true" IgnoreExitCode="true" ... />

The package is built on Windows (Build.ps1). There, Exec writes the command to a temporary .cmd file, where the single % is consumed by batch variable expansion, so git receives --format=cI and fails. Because of IgnoreExitCode="true" the error output ends up in BuildDateUtc. The line is unchanged on main.

Suggested fix

  • Make the git call work under cmd (e.g. double the % when building on Windows, or obtain the commit date without a % format string),
  • only use the output if Exec succeeded and it parses as a date, otherwise fall back, and
  • add a test that the built assembly contains a parseable BuildDateUtc, so this cannot regress silently.

🤖 Found with the help of Claude Code.

Activity

  1. jbogard commented on Oct 26, 2026

    @jbogard
    Contributor

    Thanks for the detailed report and diagnosis. You were right about the cause. It's fixed in #4666.

    Affected versions: in these published packages, BuildDateUtc contains the git error instead of a date, so perpetual licensing never applies:

    • 15.1.1 and 15.1.2
    • 16.1.0, 16.1.1 and 16.2.0

    Earlier versions and 15.1.3 don't include the perpetual licensing check, so they aren't affected.

    What to do: the fix is merged to main and will be in the next AutoMapper release. If you have a perpetual license, upgrade to that release once it's published, and perpetual licensing will apply as expected. Until then, the warning and expiry messages above will keep being logged at startup on the affected versions.

    The release build now also fails if the build date can't be embedded, so this can't regress silently.

  2. added a commit that references this issue on Oct 26, 2026
    b7bef5f
  3. jbogard commented on Oct 26, 2026

    @jbogard
    Contributor

    A correction to my earlier comment, now that we've confirmed how the 15.x line works.

    Perpetual licensing is only supported on 16.x. The 15.x line only receives critical bug fixes and security fixes, and genuine 15.x releases (15.1.0 and 15.1.3) don't include perpetual licensing.

    15.1.1 and 15.1.2 included it only because they were built from 16.x code by mistake (see #4620). Those versions are now deprecated and unlisted on NuGet.

    If you have a perpetual license, upgrade to the next 16.x release. That applies whether you're on 16.1.0–16.2.0 or on 15.1.1/15.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions