Repository navigation
SentryCreateRelease not using AssemblyInformationalVersion from Nerdbank.GitVersioning #3536
Copy link
Copy link
Closed
Labels
.NETPull requests that update .net codePull requests that update .net codeBugSomething isn't workingSomething isn't workingQuestionFurther information is requestedFurther information is requested
Description
Package
Sentry.AspNetCore
.NET Flavor
.NET
.NET Version
8.0.400
OS
Linux
SDK Version
4.10.0
Self-Hosted Sentry Version
24.7.1
Steps to Reproduce
-
Have an existing project that uses
Nerdbank.GitVersioning -
Enable the new features by adding these properties to the project config:
<SentryCreateRelease>true</SentryCreateRelease> <SentrySetCommits>true</SentrySetCommits>
-
Build the new release
Nerdbank.GitVersioning adds code at compile time:
#pragma warning disable CA2243
[assembly: System.Reflection.AssemblyVersionAttribute("2.2.0.0")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("2.2")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.2.0-alpha.1231+d4b08efa99")]
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[System.CodeDom.Compiler.GeneratedCode("Nerdbank.GitVersioning.Tasks","3.6.141.978")]
#endif
#if NET40_OR_GREATER || NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
#endif
internal static partial class ThisAssembly {
internal const string AssemblyConfiguration = "Debug";
internal const string AssemblyFileVersion = "2.2";
internal const string AssemblyInformationalVersion = "2.2.0-alpha.1231+d4b08efa99";
internal const string AssemblyName = "ExampleApp";
internal const string AssemblyTitle = "ExampleApp";
internal const string AssemblyVersion = "2.2.0.0";
internal static readonly System.DateTime GitCommitDate = new System.DateTime(638593071050000000L, System.DateTimeKind.Utc);
internal const string GitCommitId = "d4b08efa99564ae8a294e3f8888a1292f06adab7";
internal const bool IsPrerelease = true;
internal const bool IsPublicRelease = true;
internal const string RootNamespace = "ExampleApp";
}Expected Result
The version from the AssemblyInformationalVersionAttribute is being used to create the release
The following code suggests this should work: https://github.com/getsentry/sentry-dotnet/pull/3462/files#diff-14707e966a1fc6c249c6ab6fb17b0aac9349add0d80942b4710d96f7af1f0217R278
Actual Result
A release using the AssemblyVersion is created:
Getting Sentry Release...
Sentry Release: ExampleApp@2.2.0.0
Creating Sentry Release: ExampleApp@2.2.0.0
Created release ExampleApp@2.2.0.0
Setting Sentry commits
+------------------------------+--------------+
| Repository | Revision |
+------------------------------+--------------+
| ExampleApp | 428ce4f05351 |
+------------------------------+--------------+
I have not tested this without Nerdbank.GitVersioning but something is obviously wrong here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
.NETPull requests that update .net codePull requests that update .net codeBugSomething isn't workingSomething isn't workingQuestionFurther information is requestedFurther information is requested
Projects
- StatusShow more project fieldsDone
- StatusShow more project fieldsNo status
Activity
jamescrosswell commentedon Aug 15, 2024
Hi @meenzen , can you run your
dotnet buildwithdetailedlogging so that we can see what gets logged by the code that you linked to?In particular, it'd be good check if an exception is raised when trying to read the
AssemblyInformationalVersionAttribute. I think the only thing that might cause that is an AmbiguousMatchException from the Attribute.GetCustomAttribute but worth ruling this out.Otherwise, my best guess is that maybe NerdBank is applying the version information to a different assembly to the one that the Sentry build task is reading? Again, using detailed logging above would help determine that.
meenzen commentedon Aug 16, 2024
Reading the attribute does indeed fail:
Grabbing the attributes during runtime yields exactly one result as expected:
jamescrosswell commentedon Aug 16, 2024
Hm, are you able to put together a minimal reproducible example that we can look at? I'm not familiar with nerdbank and it looks like there are various ways you can integrate this.
11 remaining items
meenzen commentedon Oct 6, 2026
I put
Claude Opus 5.5up to the task and it looks like it figured out the problem:jamescrosswell commentedon Oct 7, 2026
Thanks @meenzen - reproduced and preparing a fix in :
jamescrosswell commentedon Oct 7, 2026
If
SentryCreateReleasegives you a release with the wrong version (e.g.App@1.0.0.0instead of your informational version), do one of these:SENTRY_RELEASEenvironment variable when you build, and give the app the same value at runtime, either throughSENTRY_RELEASEin its environment or throughoptions.Release.GenerateAssemblyInfoorGenerateAssemblyInformationalVersionAttributetofalse. The build will then use the same version the Sentry SDK reports at runtime.🤖 Written with Claude Code
fix: SentryCreateRelease uses the assembly's informational version an…