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

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

Top comments (0)