Skip to content

Commit 1746ab1

Browse files
[Infra] Use 8.0 packages for net8.0 where possible
Use .NET 8 packages with `net8.0` except `System.Diagnostics.DiagnosticSource`. Contributes to #5973.
1 parent 4e008ac commit 1746ab1

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

Directory.Packages.props

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@
1212
<RuntimePackageVersions>9.0.0</RuntimePackageVersions>
1313
<!--
1414
For modern .NET runtimes, match the major version of packages to the major version of the runtime.
15+
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).
1516
See https://github.com/open-telemetry/opentelemetry-dotnet/issues/5973 for more details.
16-
However, for .NET 8 we unfortunately need to use .NET 9 packages as the following APIs have been
17-
used to expose user-facing functionality:
18-
- System.Diagnostics.Activity.ctor(string, string, IEnumerable<KeyValuePair<string, object>>)
19-
- System.Diagnostics.Activity.AddException()
20-
- System.Diagnostics.Activity.AddLink()
2117
-->
22-
<RuntimePackageVersions Condition="'$(TargetFramework)' == 'net8.0'">9.0.0</RuntimePackageVersions>
18+
<RuntimePackageVersions Condition="'$(TargetFramework)' == 'net8.0'">8.0.0</RuntimePackageVersions>
2319
<RuntimePackageVersions Condition="'$(TargetFramework)' == 'net9.0'">9.0.0</RuntimePackageVersions>
2420

2521
<!-- Mitigate https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-43485. -->
@@ -33,15 +29,6 @@
3329
vulnerability in the NuGet packages that are published from this repository.
3430
-->
3531
<ItemGroup>
36-
<!--
37-
Typically, for the Microsoft.Extensions.* packages relating to DI Abstractions, Hosting Abstractions, and Logging,
38-
the latest stable version should be used because:
39-
1) Each major version bump will have some new API capabilities (e.g.For Logging, .NET 6 introduced compile-time logging
40-
source generation, .NET 8 introduced automatic event id generation).
41-
2) Each minor version bump is normally security hotfixes or critical bug fixes.
42-
3) Since version 3.1.0, the .NET runtime team is holding a high bar for backward compatibility on
43-
these packages even during major version bumps, so compatibility is not a concern here.
44-
-->
4532
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(RuntimePackageVersions)" />
4633
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Abstractions" Version="$(RuntimePackageVersions)" />
4734
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="$(RuntimePackageVersions)" />
@@ -59,15 +46,18 @@
5946
<PackageVersion Include="OpenTracing" Version="[0.12.1,0.13)" />
6047

6148
<!--
62-
Typically, the latest stable version of System.Diagnostics.DiagnosticSource should be used here because:
63-
1) Each major version bump will likely have some new OpenTelemetry capabilities (e.g. .NET 6 introduced Meter
64-
API, .NET 7 added UpDownCounter, .NET 8 added Meter/Instrument level attributes support, .NET 9 added
65-
Advice/Hint API, etc.).
66-
2) Each minor version bump is normally security hotfixes or critical bug fixes.
67-
3) The .NET runtime team provides extra backward compatibility guarantee to System.Diagnostics.DiagnosticSource
68-
even during major version bumps, so compatibility is not a concern here.
49+
For modern .NET runtimes, match the major version of packages to the major version of the runtime.
50+
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).
51+
See https://github.com/open-telemetry/opentelemetry-dotnet/issues/5973 for more details.
6952
-->
7053
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="$(RuntimePackageVersions)" />
54+
<!--
55+
However, for .NET 8 we need to use the .NET 9 package as the following APIs have been used to expose user-facing functionality:
56+
- System.Diagnostics.Activity.ctor(string, string, IEnumerable<KeyValuePair<string, object>>)
57+
- System.Diagnostics.Activity.AddException()
58+
- System.Diagnostics.Activity.AddLink()
59+
-->
60+
<PackageVersion Update="System.Diagnostics.DiagnosticSource" Version="9.0.0" Condition="'$(TargetFramework)' == 'net8.0'" />
7161
</ItemGroup>
7262

7363
<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
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>$(TargetFrameworksForTests)</TargetFrameworks>
55
<AnalysisLevel>latest-all</AnalysisLevel>
6+
<ReferenceSystemTextJsonPackages Condition="'$(TargetFramework)' == 'net8.0'">true</ReferenceSystemTextJsonPackages>
67
<!-- Avoid conflicting port registrations if TFMs tested in parallel -->
78
<TestTfmsInParallel>false</TestTfmsInParallel>
89
</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
@@ -5,6 +5,7 @@
55
<TargetFrameworks>$(TargetFrameworksForTests)</TargetFrameworks>
66
<DefineConstants>$(DefineConstants);BUILDING_HOSTING_TESTS</DefineConstants>
77
<AnalysisLevel>latest-all</AnalysisLevel>
8+
<ReferenceSystemTextJsonPackages Condition="'$(TargetFramework)' == 'net8.0'">true</ReferenceSystemTextJsonPackages>
89
</PropertyGroup>
910

1011
<ItemGroup>

0 commit comments

Comments
 (0)