Open Tratcher opened 2 years ago
@marcpopMSFT @dsplaisted @jaredpar what's happening here and is there a workaround❔ Seeing the same issue w/ the 8.0.100-alpha.1.22478.15 SDK.
The odd thing is our Microsoft.AspNetCore.Server.Kestrel.Core package uses <EnablePreviewFeatures>true</EnablePreviewFeatures>
too but is compiling cleanly. @JamesNK does that project still use preview features❔ (Both projects were updated in dotnet/aspnetcore@b120cefca18)
Yes. Some APIs are marked as preview.
@jeffhandley Is this the same issue as #28049? In this case it looks like switching to the .NET 8 SDK is breaking some stuff related to preview features in ASP.NET.
@Tratcher @dougbu Do the projects that are getting broken target .NET 7 or .NET 8?
@terrajobst
If ConnectAsync
is marked preview then I would expect this error to happen. I am surprised that moving to a 8.0.0 SDK, and doing nothing else, would trigger such a warning though. That would imply an API was not preview in 7.0.something but was in 8.0.0 alpha which seems wrong.
This line that generates the error: https://github.com/dotnet/aspnetcore/blob/c226a4b7e49a7740a27f0cfa6f517d120c57aafd/src/Servers/Kestrel/Transport.Quic/test/QuicConnectionContextTests.cs#L60
I think QuicConnection.ConnectAsync
is preview because the assembly is marked with RequiresPreviewFeaturesAttribute
. It's present in main and release/7.0.
I think QuicConnection.ConnectAsync is preview because the assembly is marked with RequiresPreviewFeaturesAttribute. It's present in main and release/7.0.
Am I understanding that the assembly shipped in 7.0 without the [ReqiresPreviewFeatures]
attribute but it got added for 8.0? If so that seems wrong. It would mean we downgraded APIs from non-preview to preview right?
Do the projects that are getting broken target .NET 7 or .NET 8?
net7.0
; we haven't made any TFM changes in main yet. (And won't until runtime changes their targets.)
That issue mentions the "workaround" of including <GenerateRequiresPreviewFeaturesAttribute>true</GenerateRequiresPreviewFeaturesAttribute>
in the project. This seems counter-intuitive, but could it help us❔
This section seems fine at first glance but would be far more understandable if a multi-targeting project could use
<EnablePreviewFeaturesForNet7.0>true</EnablePreviewFeaturesForNet7.0>
or similar. Even <EnablePreviewFeatures Condition=" '$(TargetFramework)' == 'net7.0' "
would be more understandable.
Am I understanding that the assembly shipped in 7.0 without the
[ReqiresPreviewFeatures]
attribute but it got added for 8.0?
More likely the assembly included [RequiresPreviewFeatures]
in 7.0.0 but that hasn't been removed from dotnet/runtime's main branch yet. @jeffhandley is that right❔
I think QuicConnection.ConnectAsync is preview because the assembly is marked with RequiresPreviewFeaturesAttribute. It's present in main and release/7.0.
Am I understanding that the assembly shipped in 7.0 without the
[ReqiresPreviewFeatures]
attribute but it got added for 8.0? If so that seems wrong. It would mean we downgraded APIs from non-preview to preview right?
The assembly is marked with RequiresPreviewFeaturesAttribute
in main and release/7.0:
cc @karelz
.NET 7 app with QuicConnection.ConnectAsync:
The assembly is marked with RequiresPreviewFeaturesAttribute in main and release/7.0:
That is sensible but it means I can't explain how moving to a new toolset, and doing nothing else, would cause this error. My mental model would say it needs to be paired with a change like moving to a new target framework.
My mental model would say it needs to be paired with a change like moving to a new target framework.
According to https://github.com/dotnet/designs/blob/main/accepted/2021/preview-features/preview-features.md#meaning-of-property-in-multi-targeted-projects, your mental model is upside down and backwards :grin: 😬
The generality of the preview feature msbuild
property names is questionable at best. Maybe this is only an issue w/in our repos while we're in the midst of adding a new TFM and (I hope) removing [RequiresPreviewFeatures]
from the previous release❔
According to https://github.com/dotnet/designs/blob/main/accepted/2021/preview-features/preview-features.md#meaning-of-property-in-multi-targeted-projects, your mental model is upside down and backwards 😁 😬
Well at least that explains what we're seeing.
New news: <GenerateRequiresPreviewFeaturesAttribute>true</GenerateRequiresPreviewFeaturesAttribute>
works. Didn't use it everywhere in my first attempt but that at least found other projects to change.
I found a couple of projects (src\Servers\Kestrel\test\Interop.FunctionalTests\Interop.FunctionalTests.csproj and src\Servers\Kestrel\samples\Http3SampleApp\Http3SampleApp.csproj, /fyi @JamesNK) that don't need that setting for some reason. Might no longer need <EnablePreviewFeatures>true</EnablePreviewFeatures>
❔
@dougbu Thanks for following up on this -- I see your PR was merged. May you please confirm if this is resolved and we can close the issue? Looks like we should close https://github.com/dotnet/sdk/issues/28049 as well?
@nagilson the requirement to use <EnablePreviewFeatures>true</EnablePreviewFeatures>
when building for a non-default TFM is a mess and I have no understanding of why things work that way. Read the design document and that didn't really help. Suggest this is going to trip up many external customers. To me, that means the issue should be addressed rather than papered over as we're doing now.
I see; sorry, I didn't understand the full context of the issue until now. We'll discuss this some more on our end.
Per the code, you have to be targeting the latest TFM for any of this to work. If you do, EnablePreviewFeatures will set the LangVersion to preview and GenerateRequiresPreviewFeaturesAttribute will set the preview attribute (assuming you also set the other preview property). I'm not sure how this is supposed to work and my team didn't create this feature.
@terrajobst how should this feature work? Should EnablePreviewFeatures also set GenerateRequiresPreviewFeaturesAttribute? Should we support it on older TFMs or only on the latest?
I just updated to Visual Studio release v17.4.0 and this bug is affecting all projects as I was running net6.0.
As noted in this thread,
I just updated to Visual Studio release v17.4.0 and this bug is affecting all projects as I was running net6.0...
Editing the project file helped me
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>Preview</LangVersion>
<EnablePreviewFeatures>True</EnablePreviewFeatures>
<GenerateRequiresPreviewFeaturesAttribute>True</GenerateRequiresPreviewFeaturesAttribute>
..
</PropertyGroup>
Since Visual studio 17.8.0 force installed dotnet 8 I could no longer publish projects. It seems this issue was never fixed before the version 8 release. Luckily <GenerateRequiresPreviewFeaturesAttribute>True</GenerateRequiresPreviewFeaturesAttribute>
works for now, but will this be fixed? What is the state of the preview features system?
Describe the bug
https://github.com/dotnet/aspnetcore/pull/44066 updated the SDK from 7.0 to 8.0.100-alpha.1.22469.4 and now EnablePreviewFeatures isn't working in tests and samples.
Exceptions (if any)