From 7fbfc459927ec9b2d0064430a6c2c26c3ce8db3c Mon Sep 17 00:00:00 2001 From: Andrew Lock Date: Mon, 2 Nov 2026 14:50:09 +0000 Subject: [PATCH] dotnet: use the informational version as the parametric library version The assembly version of Datadog.Trace is the same for a prerelease and its release (e.g. 3.58.0.0), but the tracer reports the semantic version (3.58.0-prerelease), so process discovery tests failed for prereleases. Read AssemblyInformationalVersion instead, without its + build metadata, falling back to the assembly version. Releases are unchanged. Co-Authored-By: Claude Opus 5.5 --- .../dotnet/GetAssemblyVersion/Program.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/utils/build/docker/dotnet/GetAssemblyVersion/Program.cs b/utils/build/docker/dotnet/GetAssemblyVersion/Program.cs index fb1dce4a4fb..d268bb74f28 100644 --- a/utils/build/docker/dotnet/GetAssemblyVersion/Program.cs +++ b/utils/build/docker/dotnet/GetAssemblyVersion/Program.cs @@ -1,10 +1,24 @@ -if (args.Length == 0 || string.IsNullOrWhiteSpace(args[0])) +using System.Reflection; + +if (args.Length == 0 || string.IsNullOrWhiteSpace(args[0])) { Console.WriteLine("Usage: GetAssemblyVersion "); return; } var fullPath = Path.GetFullPath(args[0]); -var assembly = System.Reflection.Assembly.LoadFile(fullPath); -var version = assembly.GetName().Version?.ToString(3); +var assembly = Assembly.LoadFile(fullPath); + +// Prefer the informational version (e.g. 3.58.0-prerelease+), because the assembly +// version is the same for a prerelease and its release (3.58.0.0). Drop the "+..." build metadata +// so it matches the version the tracer reports. +var informationalVersion = assembly + .GetCustomAttribute()? + .InformationalVersion + .Split('+')[0]; + +var version = string.IsNullOrWhiteSpace(informationalVersion) + ? assembly.GetName().Version?.ToString(3) + : informationalVersion; + Console.Write(version);