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

NETSDK1202 should be a warning and not an error to prevent breaking extant libaries #35811

Open Perksey opened 12 months ago

Perksey commented 12 months ago

Describe the bug

dotnet/Silk.NET is investigating upgrading to .NET 8

We support multiple out-of-support TFMs just like the BCL's extension packages do (they weren't out-of-support when we added them, but now they're added we can't remove them). We're not prepared to start removing support for older TFMs because our users are using them. It is our end user's responsibility to not use out-of-support TFMs.

Similar diagnostics, such as the warning you get when targeting .NET 5, are warnings and not errors.

To Reproduce

  1. Create a library that targets net8.0 and net6.0-android
  2. Set the global.json to point at .NET 8
  3. Install workloads (this can be done beforehand but this is the steps CI is working through)
  4. dotnet build
  5. Observe NETSDK1202

Error

  Error: /Users/runner/.dotnet/sdk/8.0.100-rc.1.23463.5/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.EolTargetFrameworks.targets(35,5): error NETSDK1202: The workload 'android' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/maui-support-policy for more information about the support policy. [/Users/runner/work/Silk.NET/Silk.NET/src/Maths/Silk.NET.Maths/Silk.NET.Maths.csproj::TargetFramework=net6.0-android]
Perksey commented 12 months ago

The error I'm thinking of is NETSDK1138 - the EOL TFM warning. This does not break downstream consumers when a framework goes out-of-support as it is not an error.

marcpopMSFT commented 11 months ago

@Perksey both 1138 and 1202 appear to be warnings: https://github.com/dotnet/sdk/blob/release/8.0.1xx/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.EolTargetFrameworks.targets

You can set CheckEolWorkloads to false to avoid this particular check .

@jonathanpeppers did a breaking change document get created for this to cover that workaround if customers didn't want to get the warning?

jonathanpeppers commented 11 months ago

@Perksey if you have a .NET 7 SDK, it is still just a warning. It is not possible to build net6.0-ios or net6.0-android apps with the .NET 8 SDK, however.

This is due to the MAUI support policy having a shorter timeline. It is basically the same policy Xamarin had:

@marcpopMSFT I don't know if this qualifies as a breaking change -- or not, but I'm willing to document this somewhere if it makes sense. This is the first time a MAUI target framework has gone out of support.

marcpopMSFT commented 11 months ago

Pinging @PriyaPurkayastha as she owns compat in case she has an opinion on where and how to document this.

PriyaPurkayastha commented 11 months ago

Just chatted with @gewarren and she mentioned that an article can be created for the warning(NETSDK1202) describing the workaround to use CheckEolWorkloads if the warning needs to be suppressed for this scenario. Editing since I noticed NETSDK1138 already has the workaround listed. The description would look something similar to it.

jonathanpeppers commented 11 months ago

Sounds good, I added NETSDK1202: https://github.com/dotnet/docs/pull/37422

Perksey commented 11 months ago

Interesting, I'm not entirely sure why we're seeing this as an error - believe me I don't have warnings as errors on, but happy with this behaviour being documented.

jonathanpeppers commented 11 months ago

We set <WarningsAsErrors>NETSDK1202</WarningsAsErrors> in the .NET 8 workloads when targeting net6.0, because we don't actually support building net6.0 projects at all with those versions.

Perksey commented 11 months ago

Makes sense! Did not know that!