Skip to content

Conversation

martincostello
Copy link
Member

@martincostello martincostello commented Jun 12, 2025

#5973 (comment)

Changes

Refactoring to match runtime packages to the major version of a target framework.

Unfortunately we can't do this complete for net8.0 without making breaking changes as we have exposed functionality that depends on new APIs added in the System.Diagnostics.DiagnosticSource package for 9.0.0.

tracer = new(new(key.Name, key.Version, key.Tags));

this.Activity!.AddLink(new ActivityLink(context, tags));

As a compromise for net8.0, 8.0.x packages are used for all dependencies except System.Diagnostics.DiagnosticSource which uses 9.0.0 to preserve these use cases.

The downside here is that users running net8.0 will technically be out of support for that package from May 2026, but that's still the case if we do nothing.

We could mitigate this by moving the special case for net8.0 to depend on the 10.0.0 package in November with a new release for .NET 10 (if that works) or users can self-mitigate by adding an explicit reference to the 10.0.0 version of that package to their own application without upgrading to .NET 10 immediately.

Moving forward to preserve the intention of this PR we would need to accept that new functionality would be gated to upgrading to the matching version of .NET. For example, a new feature added in .NET 10 would require your application to net10.0 to use it.

Alternatively we could take an approach where we only expose new APIs to older runtimes when the version is itself an LTS version.

In that case, a new API added in .NET 10 would be supported in all previous versions as we know the package exposing it is LTS, but a new API added in .NET 11 would only be available to net11.0 and later as that is STS.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added infra Infra work - CI/CD, code coverage, linters dependencies Pull requests that update a dependency file pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package labels Jun 12, 2025
Copy link

codecov bot commented Jun 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.64%. Comparing base (fb89b7a) to head (afca81a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #6327   +/-   ##
=======================================
  Coverage   86.63%   86.64%           
=======================================
  Files         258      258           
  Lines       11910    11910           
=======================================
+ Hits        10318    10319    +1     
+ Misses       1592     1591    -1     
Flag Coverage Δ
unittests-Project-Experimental 86.60% <ø> (ø)
unittests-Project-Stable 86.63% <ø> (+0.26%) ⬆️
unittests-Solution 86.59% <ø> (+0.24%) ⬆️
unittests-UnstableCoreLibraries-Experimental 85.78% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

Comment on lines 55 to 58
However, for .NET 8 we need to use the .NET 9 package as the following APIs have been used to expose user-facing functionality:
- System.Diagnostics.Activity.ctor(string, string, IEnumerable<KeyValuePair<string, object>>)
- System.Diagnostics.Activity.AddException()
- System.Diagnostics.Activity.AddLink()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be phrased to indicate that we need to (and can) use the latest version.

We, most likely, can use 10.0.x for all targets, like we can use 9.0.x.

For that matter, I'd use a property specific for this package's version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on the resolution to this comment:

Moving forward to preserve the intention of this PR we would need to accept that new functionality would be gated to upgrading to the matching version of .NET. For example, a new feature added in .NET 10 would require your application to net10.0 to use it.

Alternatively we could take an approach where we only expose new APIs to older runtimes when the version is itself an LTS version.

The PR as-is is working on the assumption new things need newer TFMs/versions, so the MSBuild as-written is correct as it would only have an exception for net8.0 and code would need to use #if NET10_0_OR_GREATER-like constructs as appropriate for future API additions.

Copy link
Member Author

@martincostello martincostello Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also written it with #6307 in mind, where if this was merged as-is it would just add these changes:

- <RuntimePackageVersions>9.0.0</RuntimePackageVersions>
+ <RuntimePackageVersions>10.0.0</RuntimePackageVersions>
+ <RuntimePackageVersions Condition="'$(TargetFramework)' == 'net10.0'">10.0.0</RuntimePackageVersions>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be prepared, but I'd reason about TFM specific stuff when we get there.

Polyfills are always an option. 😄

@eerhardt
Copy link
Contributor

Build / verify-aot-compat / run-verify-aot-compat (ubuntu-22.04, net8.0) (pull_request)Failing after 1m

Try using 8.0.2 of Microsoft.Extensions.Configuration.Binder. The 8.0.0 package has bugs in the source generator that were fixed in patched versions.

Copy link
Contributor

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will help with conflict versions of Microsoft.Extensions.* when using opentelemetry-dotnet-auto

Copy link
Contributor

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jul 30, 2025
@martincostello martincostello removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jul 30, 2025
Copy link
Contributor

github-actions bot commented Aug 7, 2025

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Aug 7, 2025
@github-actions github-actions bot removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Aug 8, 2025
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" VersionOverride="9.0.9" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martincostello
Copy link
Member Author

Dependency versions for NuGet packages before and after this change are shown below.

Changes are as expected:

  • [email protected]
    • Microsoft.Extensions.Diagnostics.Abstractions: 9.0.0 🔽 8.0.0
    • Microsoft.Extensions.Logging.Configuration: 9.0.0 🔽 8.0.0
  • [email protected]
    • Microsoft.Extensions.DependencyInjection.Abstractions: 9.0.0 🔽 8.0.0
  • [email protected]
    • Microsoft.Extensions.Configuration.Binder8.0.2 (for native AoT fixes)
  • [email protected]:
    • Microsoft.Extensions.Hosting.Abstractions: 9.0.0 🔽 8.0.0
d61f9ef (main)
{
  "OpenTelemetry": {
    ".NETFramework4.6.2": {
      "OpenTelemetry.Api.ProviderBuilderExtensions": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.Diagnostics.Abstractions": "9.0.0",
      "Microsoft.Extensions.Logging.Configuration": "9.0.0"
    },
    "net8.0": {
      "OpenTelemetry.Api.ProviderBuilderExtensions": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.Diagnostics.Abstractions": "9.0.0",
      "Microsoft.Extensions.Logging.Configuration": "9.0.0"
    },
    "net9.0": {
      "OpenTelemetry.Api.ProviderBuilderExtensions": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.Diagnostics.Abstractions": "9.0.0",
      "Microsoft.Extensions.Logging.Configuration": "9.0.0"
    },
    ".NETStandard2.0": {
      "OpenTelemetry.Api.ProviderBuilderExtensions": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.Diagnostics.Abstractions": "9.0.0",
      "Microsoft.Extensions.Logging.Configuration": "9.0.0"
    },
    ".NETStandard2.1": {
      "OpenTelemetry.Api.ProviderBuilderExtensions": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.Diagnostics.Abstractions": "9.0.0",
      "Microsoft.Extensions.Logging.Configuration": "9.0.0"
    }
  },
  "OpenTelemetry.Api": {
    ".NETFramework4.6.2": {
      "System.Diagnostics.DiagnosticSource": "9.0.0"
    },
    "net8.0": {
      "System.Diagnostics.DiagnosticSource": "9.0.0"
    },
    "net9.0": {
      "System.Diagnostics.DiagnosticSource": "9.0.0"
    },
    ".NETStandard2.0": {
      "System.Diagnostics.DiagnosticSource": "9.0.0"
    }
  },
  "OpenTelemetry.Api.ProviderBuilderExtensions": {
    ".NETFramework4.6.2": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0"
    },
    "net8.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0"
    },
    "net9.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0"
    },
    ".NETStandard2.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0"
    }
  },
  "OpenTelemetry.Exporter.Console": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.4",
      "System.Text.Encodings.Web": "4.7.2",
      "System.Text.Json": "4.7.2"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4",
      "System.Text.Json": "8.0.5"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4",
      "System.Text.Encodings.Web": "4.7.2",
      "System.Text.Json": "4.7.2"
    }
  },
  "OpenTelemetry.Exporter.InMemory": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    }
  },
  "OpenTelemetry.Exporter.OpenTelemetryProtocol": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    ".NETStandard2.1": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    }
  },
  "OpenTelemetry.Exporter.Prometheus.AspNetCore": {
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    }
  },
  "OpenTelemetry.Exporter.Prometheus.HttpListener": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    }
  },
  "OpenTelemetry.Exporter.Zipkin": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.4",
      "System.Text.Encodings.Web": "4.7.2",
      "System.Text.Json": "4.7.2"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4",
      "System.Text.Json": "8.0.5"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4",
      "System.Text.Encodings.Web": "4.7.2",
      "System.Text.Json": "4.7.2"
    }
  },
  "OpenTelemetry.Extensions.Hosting": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.Hosting.Abstractions": "9.0.0"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.Hosting.Abstractions": "9.0.0"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.Hosting.Abstractions": "9.0.0"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.4",
      "Microsoft.Extensions.Hosting.Abstractions": "9.0.0"
    }
  },
  "OpenTelemetry.Extensions.Propagators": {
    ".NETFramework4.6.2": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4"
    },
    "net8.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4"
    },
    "net9.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4"
    },
    ".NETStandard2.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4"
    }
  },
  "OpenTelemetry.Shims.OpenTracing": {
    ".NETFramework4.6.2": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4",
      "OpenTracing": "[0.12.1, 0.13.0)"
    },
    "net8.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4",
      "OpenTracing": "[0.12.1, 0.13.0)"
    },
    "net9.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4",
      "OpenTracing": "[0.12.1, 0.13.0)"
    },
    ".NETStandard2.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.4",
      "OpenTracing": "[0.12.1, 0.13.0)"
    }
  }
}
874054d
{
  "OpenTelemetry": {
    ".NETFramework4.6.2": {
      "OpenTelemetry.Api.ProviderBuilderExtensions": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.Diagnostics.Abstractions": "9.0.0",
      "Microsoft.Extensions.Logging.Configuration": "9.0.0"
    },
    "net8.0": {
      "OpenTelemetry.Api.ProviderBuilderExtensions": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.Diagnostics.Abstractions": "8.0.0",
      "Microsoft.Extensions.Logging.Configuration": "8.0.0"
    },
    "net9.0": {
      "OpenTelemetry.Api.ProviderBuilderExtensions": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.Diagnostics.Abstractions": "9.0.0",
      "Microsoft.Extensions.Logging.Configuration": "9.0.0"
    },
    ".NETStandard2.0": {
      "OpenTelemetry.Api.ProviderBuilderExtensions": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.Diagnostics.Abstractions": "9.0.0",
      "Microsoft.Extensions.Logging.Configuration": "9.0.0"
    },
    ".NETStandard2.1": {
      "OpenTelemetry.Api.ProviderBuilderExtensions": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.Diagnostics.Abstractions": "9.0.0",
      "Microsoft.Extensions.Logging.Configuration": "9.0.0"
    }
  },
  "OpenTelemetry.Api": {
    ".NETFramework4.6.2": {
      "System.Diagnostics.DiagnosticSource": "9.0.0"
    },
    "net8.0": {
      "System.Diagnostics.DiagnosticSource": "9.0.0"
    },
    "net9.0": {
      "System.Diagnostics.DiagnosticSource": "9.0.0"
    },
    ".NETStandard2.0": {
      "System.Diagnostics.DiagnosticSource": "9.0.0"
    }
  },
  "OpenTelemetry.Api.ProviderBuilderExtensions": {
    ".NETFramework4.6.2": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0"
    },
    "net8.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0"
    },
    "net9.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0"
    },
    ".NETStandard2.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0"
    }
  },
  "OpenTelemetry.Exporter.Console": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "System.Text.Encodings.Web": "4.7.2",
      "System.Text.Json": "4.7.2"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "System.Text.Json": "8.0.5"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "System.Text.Encodings.Web": "4.7.2",
      "System.Text.Json": "4.7.2"
    }
  },
  "OpenTelemetry.Exporter.InMemory": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    }
  },
  "OpenTelemetry.Exporter.OpenTelemetryProtocol": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.Configuration.Binder": "8.0.2"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    ".NETStandard2.1": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    }
  },
  "OpenTelemetry.Exporter.Prometheus.AspNetCore": {
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    }
  },
  "OpenTelemetry.Exporter.Prometheus.HttpListener": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    }
  },
  "OpenTelemetry.Exporter.Zipkin": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "System.Text.Encodings.Web": "4.7.2",
      "System.Text.Json": "4.7.2"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "System.Text.Json": "8.0.5"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "System.Text.Encodings.Web": "4.7.2",
      "System.Text.Json": "4.7.2"
    }
  },
  "OpenTelemetry.Extensions.Hosting": {
    ".NETFramework4.6.2": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.Hosting.Abstractions": "9.0.0"
    },
    "net8.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.Hosting.Abstractions": "8.0.0"
    },
    "net9.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.Hosting.Abstractions": "9.0.0"
    },
    ".NETStandard2.0": {
      "OpenTelemetry": "1.13.1-alpha.0.5",
      "Microsoft.Extensions.Hosting.Abstractions": "9.0.0"
    }
  },
  "OpenTelemetry.Extensions.Propagators": {
    ".NETFramework4.6.2": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5"
    },
    "net8.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5"
    },
    "net9.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5"
    },
    ".NETStandard2.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5"
    }
  },
  "OpenTelemetry.Shims.OpenTracing": {
    ".NETFramework4.6.2": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5",
      "OpenTracing": "[0.12.1, 0.13.0)"
    },
    "net8.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5",
      "OpenTracing": "[0.12.1, 0.13.0)"
    },
    "net9.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5",
      "OpenTracing": "[0.12.1, 0.13.0)"
    },
    ".NETStandard2.0": {
      "OpenTelemetry.Api": "1.13.1-alpha.0.5",
      "OpenTracing": "[0.12.1, 0.13.0)"
    }
  }
}

Generated with this code snippet:

Program.cs
#:property PublishAot=false

var packages = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();

foreach (var file in Directory.GetFiles(args[0], "*.nupkg", SearchOption.TopDirectoryOnly).Order())
{
    // open the file as a zip file
    using var archive = System.IO.Compression.ZipFile.OpenRead(file);
    // find the .nuspec file
    var nuspecEntry = archive.Entries.FirstOrDefault(e => e.FullName.EndsWith(".nuspec", StringComparison.OrdinalIgnoreCase));
    if (nuspecEntry == null) continue;

    using var nuspecStream = nuspecEntry.Open();
    using var reader = new StreamReader(nuspecStream);
    var nuspecContent = reader.ReadToEnd();
    var nuspecXml = System.Xml.Linq.XDocument.Parse(nuspecContent);
    var ns = nuspecXml.Root.GetDefaultNamespace();
    var metadata = nuspecXml.Root.Element(ns + "metadata");
    var id = metadata.Element(ns + "id").Value;
    var deps = metadata.Element(ns + "dependencies");
    var groups = new Dictionary<string, Dictionary<string, string>>();
    if (deps != null)
    {
        foreach (var group in deps.Elements(ns + "group"))
        {
            var tfm = group.Attribute("targetFramework")?.Value;

            if (!groups.ContainsKey(tfm))
            {
                groups[tfm] = [];
            }

            foreach (var dep in group.Elements(ns + "dependency"))
            {
                var depId = dep.Attribute("id").Value;
                var version = dep.Attribute("version")?.Value ?? "*";
                groups[tfm][depId] = version;
            }
        }
    }

    packages[id] = groups;
}

Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(packages, new System.Text.Json.JsonSerializerOptions { WriteIndented = true }));

</ItemGroup>
<!-- Version overrides for specific netX.0 TFMs -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Update="Microsoft.Extensions.DependencyInjection.Abstractions" Version="[8.0.0,)" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This result in a breaking change for net8.0. Customers may be using APIs from these libraries via transitive dependencies. We should consider maintaining this separation starting with net9 and avoid making changes to net8.

Copy link
Member Author

@martincostello martincostello Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always knew that was the case with downgrading the versions for net8.0.

It's easy for users affected by that to manually upgrade their packages manually and get back to a working state. Changing this back would undercut the whole point of the change and the already agreed issue text would need rewriting from scratch.

Use .NET 8 packages with `net8.0`, except `System.Diagnostics.DiagnosticSource`.

Resolves open-telemetry#5973.
Attempt to resolve `System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.` caused by reference to OpenTelemetry.Instrumentation.AspNetCore 1.12.0.
Update the CHANGELOGs with the dependency changes, whether direct and transitive.
@github-actions github-actions bot added pkg:OpenTelemetry.Api.ProviderBuilderExtensions Issues related to OpenTelemetry.Api.ProviderBuilderExtensions NuGet package pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package pkg:OpenTelemetry.Exporter.InMemory Issues related to OpenTelemetry.Exporter.InMemory NuGet package pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package pkg:OpenTelemetry.Exporter.Zipkin Issues related to OpenTelemetry.Exporter.Zipkin NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package labels Oct 8, 2025
@rajkumar-rangaraj
Copy link
Member

@martincostello We were preparing to merge this PR but had to hold for a hotfix, which led to some conflicts. Could you please resolve the conflicts so we can proceed with the merge?

@rajkumar-rangaraj rajkumar-rangaraj merged commit 19dda39 into open-telemetry:main Oct 9, 2025
61 checks passed
@martincostello martincostello deleted the gh-5973 branch October 9, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file infra Infra work - CI/CD, code coverage, linters keep-open Prevents issues and pull requests being closed as stale pkg:OpenTelemetry.Api.ProviderBuilderExtensions Issues related to OpenTelemetry.Api.ProviderBuilderExtensions NuGet package pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package pkg:OpenTelemetry.Exporter.InMemory Issues related to OpenTelemetry.Exporter.InMemory NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package pkg:OpenTelemetry.Exporter.Zipkin Issues related to OpenTelemetry.Exporter.Zipkin NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] targets other than net9.0 shouldn't be forced to use 9.0 dependencies
6 participants