Skip to content

Commit 6dc7587

Browse files
[Infra] Match runtime packages to runtime version
Use .NET 8 packages with `net8.0`, except `System.Diagnostics.DiagnosticSource`. Resolves #5973.
1 parent 82ea003 commit 6dc7587

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

Directory.Packages.props

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@
99
possible and only deviate (use a specific version) when a package has a
1010
more specific patch which must be reference directly.
1111
-->
12-
<LatestRuntimeOutOfBandVer>9.0.0</LatestRuntimeOutOfBandVer>
12+
<RuntimePackageVersions>9.0.0</RuntimePackageVersions>
13+
<SystemDiagnosticsDiagnosticSourceVersion>$(RuntimePackageVersions)</SystemDiagnosticsDiagnosticSourceVersion>
14+
<!--
15+
For modern .NET runtimes, match the major version of packages to the major version of the runtime.
16+
This is to ensure that the NuGet packages that users deploy match the support lifetimes of the .NET version they are using (i.e. LTS vs STS).
17+
See https://github.com/open-telemetry/opentelemetry-dotnet/issues/5973 for more details.
18+
-->
19+
<RuntimePackageVersions Condition="'$(TargetFramework)' == 'net8.0'">8.0.0</RuntimePackageVersions>
20+
<RuntimePackageVersions Condition="'$(TargetFramework)' == 'net9.0'">9.0.0</RuntimePackageVersions>
1321

1422
<!-- Mitigate https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-43485. -->
1523
<SystemTextEncodingsWebOutOfBandMinimumCoreAppVer>8.0.0</SystemTextEncodingsWebOutOfBandMinimumCoreAppVer>
@@ -22,19 +30,10 @@
2230
vulnerability in the NuGet packages that are published from this repository.
2331
-->
2432
<ItemGroup>
25-
<!--
26-
Typically, for the Microsoft.Extensions.* packages relating to DI Abstractions, Hosting Abstractions, and Logging,
27-
the latest stable version should be used because:
28-
1) Each major version bump will have some new API capabilities (e.g.For Logging, .NET 6 introduced compile-time logging
29-
source generation, .NET 8 introduced automatic event id generation).
30-
2) Each minor version bump is normally security hotfixes or critical bug fixes.
31-
3) Since version 3.1.0, the .NET runtime team is holding a high bar for backward compatibility on
32-
these packages even during major version bumps, so compatibility is not a concern here.
33-
-->
34-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(LatestRuntimeOutOfBandVer)" />
35-
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Abstractions" Version="$(LatestRuntimeOutOfBandVer)" />
36-
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="$(LatestRuntimeOutOfBandVer)" />
37-
<PackageVersion Include="Microsoft.Extensions.Logging.Configuration" Version="$(LatestRuntimeOutOfBandVer)" />
33+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(RuntimePackageVersions)" />
34+
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Abstractions" Version="$(RuntimePackageVersions)" />
35+
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="$(RuntimePackageVersions)" />
36+
<PackageVersion Include="Microsoft.Extensions.Logging.Configuration" Version="$(RuntimePackageVersions)" />
3837

3938
<!--
4039
OTel packages always point to latest stable release.
@@ -48,15 +47,11 @@
4847
<PackageVersion Include="OpenTracing" Version="[0.12.1,0.13)" />
4948

5049
<!--
51-
Typically, the latest stable version of System.Diagnostics.DiagnosticSource should be used here because:
52-
1) Each major version bump will likely have some new OpenTelemetry capabilities (e.g. .NET 6 introduced Meter
53-
API, .NET 7 added UpDownCounter, .NET 8 added Meter/Instrument level attributes support, .NET 9 added
54-
Advice/Hint API, etc.).
55-
2) Each minor version bump is normally security hotfixes or critical bug fixes.
56-
3) The .NET runtime team provides extra backward compatibility guarantee to System.Diagnostics.DiagnosticSource
57-
even during major version bumps, so compatibility is not a concern here.
50+
System.Diagnostics.DiagnosticSource is exempted from the requirement to match the major version of
51+
the runtime so that new APIs and/or semantic conventions are available to all versions of .NET.
52+
See https://github.com/open-telemetry/opentelemetry-dotnet/issues/5973 for more details.
5853
-->
59-
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="$(LatestRuntimeOutOfBandVer)" />
54+
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticsDiagnosticSourceVersion)" />
6055
</ItemGroup>
6156

6257
<ItemGroup>
@@ -96,10 +91,15 @@
9691
<PackageVersion Include="Microsoft.CSharp" Version="[4.7.0]" />
9792
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="4.14.0" />
9893
<PackageVersion Include="Microsoft.Coyote" Version="1.7.11" />
99-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(LatestRuntimeOutOfBandVer)" />
100-
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="$(LatestRuntimeOutOfBandVer)" />
101-
<PackageVersion Include="Microsoft.Extensions.Http" Version="$(LatestRuntimeOutOfBandVer)" />
102-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="$(LatestRuntimeOutOfBandVer)" />
94+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(RuntimePackageVersions)" />
95+
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="$(RuntimePackageVersions)" />
96+
<PackageVersion Include="Microsoft.Extensions.Http" Version="$(RuntimePackageVersions)" />
97+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="$(RuntimePackageVersions)" />
98+
<!--
99+
Microsoft.Extensions.Telemetry.Abstractions is not part of the .NET runtime and is supported
100+
at "tip", however the package multi-targets so that its dependencies match the major version
101+
of the runtime for each target framework so always uses the latest major version.
102+
-->
103103
<PackageVersion Include="Microsoft.Extensions.Telemetry.Abstractions" Version="[9.0.0,)" />
104104
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="[1.0.3,2.0)" />
105105
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.13.0,18.0.0)" />

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
<AllowUnsafeBlocks Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'">true</AllowUnsafeBlocks>
2020
</PropertyGroup>
2121

22+
<!-- This package is explicitly upgraded for .NET 8 to fix native AoT compatibility issues -->
23+
<ItemGroup>
24+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" VersionOverride="8.0.2" Condition="'$(TargetFramework)' == 'net8.0'" />
25+
</ItemGroup>
26+
2227
<ItemGroup>
2328
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
2429
</ItemGroup>

test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>$(TargetFrameworksForTests)</TargetFrameworks>
5+
<ReferenceSystemTextJsonPackages Condition="'$(TargetFramework)' == 'net8.0'">true</ReferenceSystemTextJsonPackages>
56
<!-- Avoid conflicting port registrations if TFMs tested in parallel -->
67
<TestTfmsInParallel>false</TestTfmsInParallel>
78
</PropertyGroup>

test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetry.Extensions.Hosting.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<Description>Unit test project for OpenTelemetry .NET Core hosting library</Description>
55
<TargetFrameworks>$(TargetFrameworksForTests)</TargetFrameworks>
66
<DefineConstants>$(DefineConstants);BUILDING_HOSTING_TESTS</DefineConstants>
7+
<ReferenceSystemTextJsonPackages Condition="'$(TargetFramework)' == 'net8.0'">true</ReferenceSystemTextJsonPackages>
78
</PropertyGroup>
89

910
<ItemGroup>

0 commit comments

Comments
 (0)