Skip to content

Commit b2cf29f

Browse files
[Infra] Prepare to match runtime packages to runtime version
Refactoring to prepare to match runtime packages to the major version of a target framework. Unfortunately we can't do this for `net8.0` without making breaking changes as we have exposed functionality that depends on new APIs added in the System.Diagnostics.DiagnosticSource package. Contributes to #5973.
1 parent 1479b23 commit b2cf29f

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

Directory.Packages.props

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,18 @@
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+
<!--
14+
For modern .NET runtimes, match the major version of packages to the major version of the runtime.
15+
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()
21+
-->
22+
<RuntimePackageVersions Condition="'$(TargetFramework)' == 'net8.0'">9.0.0</RuntimePackageVersions>
23+
<RuntimePackageVersions Condition="'$(TargetFramework)' == 'net9.0'">9.0.0</RuntimePackageVersions>
1324

1425
<!-- Mitigate https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-43485. -->
1526
<SystemTextEncodingsWebOutOfBandMinimumCoreAppVer>8.0.0</SystemTextEncodingsWebOutOfBandMinimumCoreAppVer>
@@ -31,10 +42,10 @@
3142
3) Since version 3.1.0, the .NET runtime team is holding a high bar for backward compatibility on
3243
these packages even during major version bumps, so compatibility is not a concern here.
3344
-->
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)" />
45+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(RuntimePackageVersions)" />
46+
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Abstractions" Version="$(RuntimePackageVersions)" />
47+
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="$(RuntimePackageVersions)" />
48+
<PackageVersion Include="Microsoft.Extensions.Logging.Configuration" Version="$(RuntimePackageVersions)" />
3849

3950
<!--
4051
OTel packages always point to latest stable release.
@@ -56,7 +67,7 @@
5667
3) The .NET runtime team provides extra backward compatibility guarantee to System.Diagnostics.DiagnosticSource
5768
even during major version bumps, so compatibility is not a concern here.
5869
-->
59-
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="$(LatestRuntimeOutOfBandVer)" />
70+
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="$(RuntimePackageVersions)" />
6071
</ItemGroup>
6172

6273
<ItemGroup>
@@ -96,10 +107,15 @@
96107
<PackageVersion Include="Microsoft.CSharp" Version="[4.7.0]" />
97108
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="[3.11.0-beta1.23525.2]" />
98109
<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)" />
110+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(RuntimePackageVersions)" />
111+
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="$(RuntimePackageVersions)" />
112+
<PackageVersion Include="Microsoft.Extensions.Http" Version="$(RuntimePackageVersions)" />
113+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="$(RuntimePackageVersions)" />
114+
<!--
115+
Microsoft.Extensions.Telemetry.Abstractions is not part of the .NET runtime and is supported
116+
at "tip", however the package multi-targets so that its dependencies match the major version
117+
of the runtime for each target framework so always uses the latest major version.
118+
-->
103119
<PackageVersion Include="Microsoft.Extensions.Telemetry.Abstractions" Version="[9.0.0,)" />
104120
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="[1.0.3,2.0)" />
105121
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.13.0,18.0.0)" />

0 commit comments

Comments
 (0)