dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.67k stars 1.06k forks source link

[API Compat] Not targeting .NET 8 framework in versions 8.* #43801

Open dosper7 opened 2 days ago

dosper7 commented 2 days ago

I am building a CI/CD pipeline using a .NET 8-based container image. In this pipeline, I have a validation step where I want to check for potential breaking changes and fail if any are detected. To my surprise, when I installed the Microsoft.DotNet.ApiCompat.Tool and tried to use it, it failed because it targets the .NET 6 framework, which I do not have installed.

apicompat --version
8.0.401+41b13414c4a35aac269719f7281cf74c9c9aae31

Installing the .NET 6 runtime makes the tool work (version 6.0.33):

    wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
    chmod +x dotnet-install.sh
    ./dotnet-install.sh --runtime dotnet --version 6.0.33

Question:

Why isn't there version parity between the API Compat tool version 8.* and its dependent framework?

When I check the API Compat tool version 8.0.4 on the NuGet Package Explorer, I see it has a dependency on .NET 6: image

If I inspect a more recent version (e.g., .NET 9 RC), I notice it depends on the latest LTS version (.NET 8), whereas I was expecting it to depend on .NET 9: image

I realize I might be missing something, but I would like to understand the rationale or reasons behind this discrepancy. Can you help?

dotnet-policy-service[bot] commented 2 days ago

@dotnet/area-infrastructure-libraries a new issue has been filed in the ApiCompat area, please triage

KalleOlaviNiemitalo commented 2 days ago

If I inspect a more recent version (e.g., .NET 9 RC), I notice it depends on the latest LTS version (.NET 8)

That's intentional in https://github.com/dotnet/sdk/pull/38485

dosper7 commented 23 hours ago

If I inspect a more recent version (e.g., .NET 9 RC), I notice it depends on the latest LTS version (.NET 8)

That's intentional in #38485

That means that .NET 8 base containers can't run Api Compat without having the .NET 6 runtime installed?

KalleOlaviNiemitalo commented 20 hours ago

Well my comment was only for the net9 rc version of the tool.

But IIRC an option was added to dotnet tool install to allow running any tool on a higher version of .NET Runtime than it targets (major version roll-forward). I don't remember whether that is in .NET SDK 8 or only in 9. Doesn't seem to be documented at https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-tool-install yet.

KalleOlaviNiemitalo commented 18 hours ago

The dotnet tool install --allow-roll-forward feature was https://github.com/dotnet/sdk/pull/37231 and it's in .NET SDK 8.0.300.

For older SDKs, you can use the DOTNET_ROLL_FORWARD environment variable.

KalleOlaviNiemitalo commented 18 hours ago

As for why Microsoft.DotNet.ApiCompat.Tool 8.0.402 targets .NET 6, I don't know the official reason but I'd guess that they wanted to have some version of the tool runnable on .NET 6 LTS until that goes out of support; no 6.* version of the tool was published; the 7.* versions of the tool were built as part of .NET SDK 7 which is already out of support; so the responsibility falls to 8.* versions of the tool. They could have made it multitarget .NET 6 and .NET 8 though.