|
| 1 | +# Updating Microsoft depenencies to match the target framework version |
| 2 | + |
| 3 | +After [requests from OpenTelemetry's users][issue], in a future release the .NET |
| 4 | +OpenTelemetry libraries are changing the strategy they use for selecting the |
| 5 | +versions of NuGet packages they depend on that are shipped by the .NET team |
| 6 | +as part of the core .NET platform (for example `System.Text.Json`). |
| 7 | + |
| 8 | +If you would like to know the background to this, then continue reading this |
| 9 | +issue. If you only want to see a summary of the outcome, skip to the end of |
| 10 | +this issue. |
| 11 | + |
| 12 | +## Problem |
| 13 | + |
| 14 | +This change attempts to balance two competing perspectives on the way our |
| 15 | +dependency versions are managed in the most flexible and pragmatic way. |
| 16 | + |
| 17 | +On the one hand, one group of users want to always use the latest-and-greatest version |
| 18 | +of the .NET platform whatever target framework they target in their own projects. |
| 19 | + |
| 20 | +On the other hand, another group of users prefer to keep their dependencies aligned |
| 21 | +with the version of .NET that they use in their applications. For example, users |
| 22 | +who only wish to use Long Term Support (LTS) versions of .NET do not wish to also |
| 23 | +deploy Standard Term Support (STS) versions of .NET dependencies with their |
| 24 | +published application. A concrete example of this would be an application targeting |
| 25 | +.NET 8 not including any packages from .NET 9. |
| 26 | + |
| 27 | +The approach which matches the wishes of the first group of users forces this behaviour |
| 28 | +onto users in the second group. It is not possible for users in the second group |
| 29 | +to downgrade the versions of the dependencies included with an application using |
| 30 | +OpenTelemetry. They have no flexibility to change this. |
| 31 | + |
| 32 | +However, the approach which matches the wishes of the second group of users does |
| 33 | +not force this view on the first group, who are able to opt into upgrading the |
| 34 | +dependencies in their applications to newer versions themselves if they wish to. |
| 35 | + |
| 36 | +Features such as [package reference pruning][prune-package-reference] (added in |
| 37 | +.NET 9), [Transitive Pinning][transitive-pinning], or adding an explicit package |
| 38 | +reference to one or more projects with a `<PackageReference>` element can be used |
| 39 | +by users in the first group to upgrade the dependencies they would otherwise only |
| 40 | +have in their applications' dependency graph through their use of the OpenTelemetry |
| 41 | +packages. |
| 42 | + |
| 43 | +This approach would allow users of applications targeting `net9.0` to upgrade to |
| 44 | +the `10.0.x` packages of their own accord once .NET 10 is released without also needing |
| 45 | +to upgrade their applications to target `net10.0`. |
| 46 | + |
| 47 | +## Solution |
| 48 | + |
| 49 | +The solution to this problem is implemented by [this pull request][pull-request]. |
| 50 | + |
| 51 | +The change is to have the major versions of packages such as `Microsoft.Extensions.*` |
| 52 | +and `System.Text.Json` aligned to the major version of the target framework the assembly |
| 53 | +is compiled for. |
| 54 | + |
| 55 | +For .NET 9 this would be `9.0.x`, for .NET 10 this would be `10.0.x`, etc. |
| 56 | + |
| 57 | +There is however some nuance to this, rather than a simple alignment as illustrated |
| 58 | +above. |
| 59 | + |
| 60 | +By default the `x.0.0` package versions will be used, but individual packages may |
| 61 | +be upgraded to later patch versions, if needed, to address functional and/or security |
| 62 | +issues. |
| 63 | + |
| 64 | +### Exceptions |
| 65 | + |
| 66 | +#### .NET Framework and netstandard2.x |
| 67 | + |
| 68 | +For .NET Framework and `netstandard2.x` only, the `Microsoft.Extensions.*` and |
| 69 | +`System.Text.Json` packages will always track the latest version of .NET. This means |
| 70 | +they will stay aligned to `9.0.x` at the time of writing, and will move to `10.0.x` |
| 71 | +after the release of .NET 10, `11.0.x` after the release of .NET 11 in 2026, and |
| 72 | +so on. |
| 73 | + |
| 74 | +This is because these target frameworks are disconnected from the yearly update cadence |
| 75 | +of .NET, particularly for .NET Framework, so we keep them updated to keep pace with |
| 76 | +innovation in the .NET stack and to ingest any security fixes over time. |
| 77 | + |
| 78 | +#### System.Diagnostics.DiagnosticSource |
| 79 | + |
| 80 | +The `System.Diagnostics.DiagnosticSource` package will always track the latest |
| 81 | +version of .NET and will not align to the target framework. |
| 82 | + |
| 83 | +There are two reasons for this: |
| 84 | + |
| 85 | +1. As this package provides the core functionality OpenTelemetry builds upon |
| 86 | + (e.g. `Activity`, `Meter`), this library needs to be kept up-to-date to leverage |
| 87 | + changes to OpenTelementry functionality as the standards evolve over time as |
| 88 | + changes to Semantic Conventions etc. will not be backported to previous releases |
| 89 | + of the .NET platform. |
| 90 | +2. Prior to this change, the `System.Diagnostics.DiagnosticSource` package already |
| 91 | + always used the latest version, and APIs only present in the `9.0.x` versions |
| 92 | + were depended on for all target frameworks. Downgrading this version for `net8.0` |
| 93 | + would then break functionality for OpenTelemetry users of applications targeting |
| 94 | + .NET 8 as these APIs would be missing. |
| 95 | + |
| 96 | +## Summary of changes |
| 97 | + |
| 98 | +| **Target Framework** | **Updated Package Version** | **Effective Change** | |
| 99 | +|:---------------------|----------------------------:|:------------------------------------------| |
| 100 | +| `netstandard2.0` | `${latest}.0.x` | **None** - continues to track `${latest}` | |
| 101 | +| `net8.0` | `8.0.x`[^1] | Will **not** upgrade to `10.0.x`[^1] | |
| 102 | +| `net9.0` | `9.0.x`[^1] | Will **not** upgrade to `10.0.x`[^1] | |
| 103 | +| `net10.0` | `10.0.x`[^1] | Will stay pinned to `10.0.x`[^1] | |
| 104 | +| `net11.0` | `11.0.x`[^1] | Will stay pinned to `11.0.x`[^1] | |
| 105 | + |
| 106 | +[^1]: Except for `System.Diagnostics.DiagnosticSource`, which will always track `${latest}.0.x` |
| 107 | + |
| 108 | +[issue]: https://github.com/open-telemetry/opentelemetry-dotnet/issues/5973 |
| 109 | +[prune-package-reference]: https://learn.microsoft.com/nuget/consume-packages/package-references-in-project-files#prunepackagereference |
| 110 | +[pull-request]: https://github.com/open-telemetry/opentelemetry-dotnet/pull/6327 |
| 111 | +[transitive-pinning]: https://learn.microsoft.com/nuget/consume-packages/central-package-management#transitive-pinning |
0 commit comments