DEV Community

Cover image for Remove git hash from assembly informational version in .NET 8
Anthony Simmon
Anthony Simmon

Posted on • Originally published at anthonysimmon.com

1

Remove git hash from assembly informational version in .NET 8

If you build your .NET projects with the .NET 8 SDK, you may have noticed that the assembly informational version now includes the git hash of the associated commit:

var informationalVersion = typeof(Program).Assembly
    .GetCustomAttribute<AssemblyInformationalVersionAttribute>()
    .InformationalVersion;

Console.WriteLine(informationalVersion);

// Prints something like
// 1.0.0+9aa8e4c69145f5b7b4b59c93f2a1ee5ea19b79f9
Enter fullscreen mode Exit fullscreen mode

This is a breaking change in the .NET 8 SDK, which now includes Source Link by default. Source Link allows packages and applications to embed information about the source control of generated artifacts. This affects any target framework, as long as the code is compiled with the .NET 8 SDK.

If you had logic that uses the assembly informational version, it might not work at all anymore. To opt out of this feature, you need to add the following property in your .csproj file:

<PropertyGroup>
  <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
Enter fullscreen mode Exit fullscreen mode

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay