Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET SDK 8.0.404 ignores <EnablePreviewFeatures>True in dotnet build #44985

Closed
alexandrehtrb opened this issue Nov 18, 2024 · 5 comments
Closed
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@alexandrehtrb
Copy link

alexandrehtrb commented Nov 18, 2024

Description

Hello,

I have a project with the following code line, that requires <EnablePreviewFeatures>True</EnablePreviewFeatures> in the csproj.

if (httpVersion == 3.0m && !(OperatingSystem.IsLinux() || QuicConnection.IsSupported))

When running dotnet build on the pipeline, this error pops up:

Error: D:\a\Pororoca\Pororoca\src\Pororoca.Domain\Features\Common\AvailablePororocaRequestSelectionOptions.cs(42,67): 
error CA2252: Using 'IsSupported' requires opting into preview features. 
See https://aka.ms/dotnet-warnings/preview-features for more information. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2252) [D:\a\Pororoca\Pororoca\src\Pororoca.Domain\Pororoca.Domain.csproj]
    0 Warning(s)
    1 Error(s)

Even though the .csproj has this flag specified.

Regression?

The bug happens with .NET SDK 8.0.404, but it does not happen with 8.0.403.

Configuration

Win x64 machine. I didn't check on Linux machine.

@dotnet-policy-service dotnet-policy-service bot added the untriaged Request triage from a team member label Nov 18, 2024
@alexandrehtrb
Copy link
Author

I ran another workflow run and this bug appeared with 8.0.403 too 🤨

@alexandrehtrb
Copy link
Author

Should this issue be moved to the dotnet/sdk repo?

@jtschuster
Copy link
Member

Yes, I think dotnet/sdk would be the best place for this

@jtschuster jtschuster transferred this issue from dotnet/runtime Nov 20, 2024
@KalleOlaviNiemitalo
Copy link
Contributor

Are you using global.json to make sure that the .NET SDK version is what you expect?

https://github.com/dotnet/designs/blob/main/accepted/2021/preview-features/preview-features.md#sdk-support-of-preview-features says:

The .NET SDK only supports preview features for the current framework. More specifically, <EnablePreviewFeatures> is ignored for all other frameworks.

So if you were somehow accidentally using .NET SDK 9.0.100, but still targeting net8.0, then EnablePreviewFeatures would be ignored.

@alexandrehtrb
Copy link
Author

I was setting the SDK version with GitHub Actions and expected to be the only version installed, but .NET 9 SDK was installed too, and it was being used instead.

After adding a global.json, the project started to compile again.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants