Open
Description
Describe the bug
When a project has an ASP.NET framework reference directly:
<FrameworkReference Include="Microsoft.AspNetCore.App" />
Or through some project reference to another project (web or as above) it will get a reference to source generators, but not get the web SDK targets. This won't happen for non-aspnet framework references since in those cases the project would take a Configuration package reference which brings in the targets.
These are the settings that are missing:
We had discussed that the publish AOT defaults might be OK, but missing InterceptorsPreviewNamespaces
results in a compile time error when the user has opted into the generator.
I this this porting eShopOnContainers and had to set the property myself.
CC @captainsafia @eerhardt @tarekgh @eiriktsarpalis
To Reproduce
- create a new non-web project
- Add
<FrameworkReference Include="Microsoft.AspNetCore.App" />
- Add
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
- Use configuration:
using Microsoft.Extensions.Configuration;
var c = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string,string?>()
{
["Value"] = "42",
})
.Build();
C value = new();
c.Bind(value);
class C { public int Value { get; set; } }
Exceptions (if any)
C:\scratch\configNotWeb\Microsoft.Extensions.Configuration.Binder.SourceGeneration\Microsoft.Extensions.Configuration.Binder.SourceGeneration.ConfigurationBindingGenerator\BindingExtensions.g.cs(34,10): error CS9137: The 'interceptors' experimental feature is not enabled in this namespace. Add '<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);Microsoft.Extensions.Configuration.Binder.SourceGeneration</InterceptorsPreviewNamespaces>' to your project. [C:\scratch\configNotWeb\configNotWeb.csproj]
Further technical details
- Include the output of
dotnet --info
C:\scratch\configNotWeb>dotnet --info
.NET SDK:
Version: 8.0.100-rc.2.23502.2
Commit: 0abacfc2b6
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.100-rc.2.23502.2\